#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 4e6 + 5;
int a[N];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) a[i] = i + 1;
  int L = 0, R = n - 1;
  for (int i = 2; i <= n; ++i) {
    for (int k = (n - 1) / i; k > 0; --k)
      swap(a[L + (k - 1) * i], a[L + k * i]);
    ++R;
    a[R] = a[L];
    ++L;
  }
  for (int i = 0; i < n; ++i) printf("%d%s", a[L + i], i == n - 1 ? "\n" : " ");
  return 0;
}

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/*
 public class _287D {

 }

 */
public class _287D {
  public void solve() throws FileNotFoundException {
    InputStream inputStream = System.in;

    InputHelper in = new InputHelper(inputStream);

    // actual solution
    int n = in.readInteger();

    int[] a = new int[2 * n];

    for (int i = 0; i < n; i++) {
      a[i] = i + 1;
    }

    int s = 0, e = n - 1;

    for (int i = 2; i <= n; i++) {

      int t1 = a[s];
      int t2 = -1;
      for (int j = s + i;; j += i) {
        if (j > e + 1) {
          j = e + 1;
        }
        t2 = a[j];
        a[j] = t1;
        t1 = t2;

        if (j == e + 1)
          break;
      }

      s++;
      e++;
    }

    StringBuilder sb = new StringBuilder();

    for (int i = n - 1; i < 2 * n - 1; i++) {
      sb.append(a[i] + " ");
    }

    System.out.println(sb.toString());
    // end here
  }

  public static void main(String[] args) throws FileNotFoundException {
    (new _287D()).solve();
  }

  class InputHelper {
    StringTokenizer tokenizer = null;
    private BufferedReader bufferedReader;

    public InputHelper(InputStream inputStream) {
      InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
      bufferedReader = new BufferedReader(inputStreamReader, 16384);
    }

    public String read() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          String line = bufferedReader.readLine();
          if (line == null) {
            return null;
          }
          tokenizer = new StringTokenizer(line);
        } catch (IOException e) {
          e.printStackTrace();
        }
      }

      return tokenizer.nextToken();
    }

    public Integer readInteger() {
      return Integer.parseInt(read());
    }

    public Long readLong() {
      return Long.parseLong(read());
    }
  }
}


import java.util.Scanner;

public class C_132A {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int [n];
		for (int i = 0; i < a.length; i++) {
			a[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int b[] = new int [m];
		for (int i = 0; i < b.length; i++) {
			b[i] = sc.nextInt();
		}
		int max = -1;
		for (int i = 0; i < b.length; i++) {
			for (int j = 0; j < a.length; j++) {
				if(b[i] % a[j] == 0) max = Math.max(max, b[i]/a[j]);
			}
		}
		int ans = 0;
		for (int i = 0; i < b.length; i++) {
			for (int j = 0; j < a.length; j++) {
				if((double) b[i] / a[j] ==  max)  ans++;
			}
		}
		System.out.println(ans);
	}
}

n = int(input())
a = list(map(int,input().split()))
m = int(input())
b = list(map(int,input().split()))
count = []
for i in range(n):
    for j in range(m):
        if((b[j]/a[i])==int(b[j]/a[i])):
            count.append(int(b[j]/a[i]))
o = max(count)
print(count.count(o))


import java.io.*;
import java.util.*;

public class dynasty {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[][] dp = new int[26][26];
		//starting, ending
		int ans = 0;
		for (int i = 0; i < n; i++) {
			String name = br.readLine();
			int lval = ((int) name.charAt(name.length()-1))-97;
			int fval = ((int) name.charAt(0))-97;
			for (int j = 0; j < 26; j++) {
				if (dp[j][fval] != 0) {
					dp[j][lval] = Integer.max(dp[j][fval]+name.length(), dp[j][lval]);

				} else if (fval == j) {
					dp[j][lval] = Integer.max(name.length(), dp[j][lval]);
				}
			}
		}
		int c = 0;
		for (int r = 0; r < 26; r++) {
			ans = Integer.max(dp[r][c], ans);
			c++;
		}
		System.out.println(ans);
	}
}

100
d
a
e
eb
c
d
d
e
c
e
ac
d
c
aa
a
e
da
e
e
c
e
a
c
c
bc
bd
d
da
cc
be
b
a
ee
d
be
be
e
b
a
ed
cb
ab
a
ea
ac
aa
ed
d
b
eb
e
ed
c
ce
c
d
c
d
d
ee
e
b
ea
ea
da
ab
ba
ed
da
ec
ea
bd
ee
dc
d
bd
d
c
cc
ab
bd
a
ad
e
d
e
bc
bb
c
bc
a
a
e
ca
ac
c
ad
c
be
d

10
abdcced
bdacdac
ecb
dc
eaeeebdd
adcdbadcac
eb
aadecccde
edbaeacad
accd

from sys import stdin, stdout

fst = 97
sze = 26

values = [[0 for i in range(sze)] for j in range(sze)]
n = int(stdin.readline())
challengers = []

for i in range(n):
    s = stdin.readline().strip()
    challengers.append((ord(s[0]) - fst, ord(s[-1]) - fst))

    for i in range(sze):
        if values[i][challengers[-1][0]]:
            values[i][challengers[-1][1]] = max(values[i][challengers[-1][1]], values[i][challengers[-1][0]] + len(s))

    values[challengers[-1][0]][challengers[-1][1]] = max(values[challengers[-1][0]][challengers[-1][1]], len(s))

ans = 0
for i in range(sze):
    ans = max(ans, values[i][i])

stdout.write(str(ans))


import java.io.*;
import java.util.*;

public class Main {

    static point a[];

    static int check(int wx, int wy, int sx, int sy) { //waurma
        int cnt = 0;
        for (int i = 0; i < a.length; i++) {
            int x = a[i].x;
            int y = a[i].y;
            if (wx >= Math.min(sx, x) && wy >= Math.min(sy, y) && wx <= Math.max(sx, x) && wy <= Math.max(sy, y)) cnt++;
        }
        return cnt;
    }

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = nextInt();
        int sx = nextInt();
        int sy = nextInt();
        a = new point[n];
        for (int i = 0; i < n; i++) {
            a[i] = new point(nextInt(), nextInt());
        }
        cf b = new cf(check(sx - 1, sy, sx, sy), sx - 1, sy);
        cf c = new cf(check(sx + 1, sy, sx, sy), sx + 1, sy);
        cf d = new cf(check(sx, sy - 1, sx, sy), sx, sy - 1);
        cf e = new cf(check(sx, sy + 1, sx, sy), sx, sy + 1);
        TreeSet<cf> ts = new TreeSet<>((o1, o2) -> Integer.compare(o1.value, o2.value));
        ts.add(b);
        ts.add(c);
        ts.add(d);
        ts.add(e);
        out.println(ts.last().value);
        out.println(ts.last().x + " " + ts.last().y);
        out.close();
    }

    static BufferedReader br;
    static StringTokenizer st = new StringTokenizer("");

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

}

class point {
    int x, y;

    public point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

class cf {
    int value, x, y;

    public cf(int value, int x, int y) {
        this.value = value;
        this.x = x;
        this.y = y;
    }
}

n,x,y=map(int,input().split())
lu=0
ld=0
ru=0
rd=0
u=0
d=0
l=0
r=0

for i in range(n):
    a,b=map(int,input().split())
    if(a<x and b<y):
        ld+=1
    elif(a<x and b>y):
        lu+=1
    elif(a==x and b!=y):
        if(b>y):
            u+=1
        else:
            d+=1
    elif(a>x and b<y):
        rd+=1
    elif(a>x and b>y):
        ru+=1
    elif(a!=x and b==y):
        if(a<x):
            l+=1
        else:
            r+=1

l1=[]
#print(lu,ru,ld,rd,u,d,l,r)
l1.append(lu+ru+u)
l1.append(lu+ld+l)
l1.append(ru+rd+r)
l1.append(ld+rd+d)
ans=max(l1)
ind=l1.index(max(l1))
print(ans)
if(ind==0):
    print(x,y+1)
elif(ind==1):
    print(x-1,y)
elif(ind==2):
    print(x+1,y)
else:
    print(x,y-1)


list1 = list(map(int, input().split()))
list1.sort()
if list1[0] + list1[3] == list1[1] + list1[2]:
    print("YES")
elif list1[0] + list1[2] +list1[1] == list1[3]:
    print("YES")
else:
    print("NO")

import java.util.Scanner;

/**
 *
 * @author MiloMurphy
 */
public class DashaA {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
        int b = s.nextInt();
        int c = s.nextInt();
        int d = s.nextInt();

        if((a + b) == (c + d)){
            System.out.println("YES");
        }else if((a + c) == ( b + d)){
            System.out.println("YES");
        }else if((a + d) == (b + c)){
            System.out.println("YES");
        }else if(a == (b + c + d)){
            System.out.println("YES");
        }else if(b == (a + c + d)){
            System.out.println("YES");
        }else if(c == (a + b + d)){
            System.out.println("YES");
        }else if(d == (a + b + c)){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }

    }

}


import java.io.*;
import java.util.*;
import java.util.regex.*;
public class vk18
{
    public static void main(String[]stp) throws Exception
    {
    	Scanner scan=new Scanner(System.in);
    	PrintWriter pw = new PrintWriter(System.out);
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer(br.readLine());
        long n=Long.parseLong(st.nextToken());
        int i,m=Integer.parseInt(st.nextToken());
        long k=Long.parseLong(st.nextToken());
        Long a[]=new Long[m];
        st=new StringTokenizer(br.readLine());
        for(i=0;i<m;i++) a[i]=Long.parseLong(st.nextToken());
        long off=0,ans=0;
    	for(i=0;i<m;i++)
    	{
    		long page=(a[i]-off-1)/k,count=0;
    		while(i < m && (a[i]-off-1)/k == page) { count++; i++; }
    		off+=count;
    		ans++;
    		i--;
    	}
    	pw.println(ans);
    	pw.flush();
	}
}

#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  long long arr[m];
  for (long long i = 0; i < m; i++) cin >> arr[i];
  long long ans = 0;
  long long sub = 0;
  long long g = 1, temp;
  long long now = (arr[0] - 1) / k;
  ;
  for (long long i = 1; i < m; i++) {
    temp = (arr[i] - 1 - sub) / k;
    if (now == temp)
      g++;
    else {
      sub += g;
      g = 1;
      temp = (arr[i] - 1 - sub) / k;
      now = temp;
      ans++;
    }
  }
  cout << ans + 1;
}


n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aeven = 0
aodd = 0
beven = 0
bodd = 0
for i in range(n):
    if a[i] % 2 == 0:
        aeven += 1
    else:
        aodd += 1

for i in range(m):
    if b[i] % 2 == 0:
        beven += 1
    else:
        bodd += 1

print(min(aeven, bodd)+min(aodd, beven))

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m, i, j, a, b, o = 0, e = 0, o1 = 0, e1 = 0, c, d;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a;
    if (a % 2 == 1)
      o++;
    else
      e++;
  }
  for (j = 0; j < m; j++) {
    cin >> b;
    if (b % 2 == 1)
      o1++;
    else
      e1++;
  }
  c = min(o, e1);
  d = min(o1, e);
  cout << c + d;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 4;
const int mod = 1e9 + 7;
int dp[N];
char a[N];
int main() {
  scanf("%s", a + 1);
  int n = strlen(a + 1);
  int sum = 0;
  int ans = 0;
  int flag = 0;
  for (int i = 1; i <= n;) {
    if (a[i] == 'a') {
      dp[i] = sum + 1;
      dp[i] %= mod;
      ans += dp[i];
      ans %= mod;
    } else if (a[i] == 'b') {
      sum += ans;
      sum %= mod;
      ans = 0;
      while (a[i] != 'a' && i <= n) i++;
      i--;
    }
    i++;
  }
  sum = 0;
  for (int i = 1; i <= n; i++) {
    sum = sum + dp[i];
    sum %= mod;
  }
  cout << sum << endl;
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class B {

	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		char [] c = sc.next().toCharArray();
		int a = 0;
		long ans = 1L;
		for (int i = 0; i < c.length; ++i) {
			if(c[i] == 'b'){
				ans = mul(ans, a+1);
				a = 0;
			}
			else if(c[i] == 'a')
				++a;
		}
		ans = mul(ans, a+1);
		out.println((ans-1+mod)%mod);
		out.close();
	}
	static final int mod = (int)1e9+7;
	static int mul(long a, long b){
		return (int) (a * b % mod);
	}
	static int add(long a, long b){
		return (int) ((a + b) % mod);
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		public Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(br.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}
		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
	}

}


i = input()
i = int(i)
v = 0
g = 2
s = 4
while g <= i:
	while s <= i:
		v = v + int(s / g * 4)
		s = s + g
	g = g + 1
	s = g * 2
print(str(v))

import java.util.*;
import java.io.*;
public class Main
{
      static int n;
      static long[] s;
      static ArrayList<Integer> p;
      static void sieve()
      {
            int x = (int)1e5;
            p = new ArrayList<Integer>();
            boolean prime[] = new boolean[x+1];
            for(int i = 0 ; i < x ; i++) prime[i] = true;
            for(int p = 2; p*p <= x; p++)
            {
                  if(prime[p] == true)
                  {
                        for(int i = p*p; i <= x; i += p) prime[i] = false;
                  }
            }
            for(int i = 2; i <= x; i++)
            {
                  if(prime[i] == true) p.add(i);
            }
      }
      public static long sigma(int x)
      {
            if(Collections.binarySearch(p,x) >= 0) return (x + 1);
            if(x == 1) return 1;
            if(s[x] > 0) return s[x];
            int k = 0;
            int pow = 0;
            int prime = p.get(0);
            Loop:
            while(true)
            {
                  if(x % prime == 0)
                  {
                        pow++;
                        x /= prime;
                  }
                  else
                  {
                        if(pow > 0) break Loop;
                        prime = p.get(++k);
                  }
            }
            if(x == 1) return ((long)Math.pow(prime,pow+1) - 1)/((long)prime - 1);
            return (sigma((int)Math.pow(prime,pow)) * sigma(x));
      }
	public static void main (String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		sieve();
		s = new long[n+1];
		for(int i = 1 ; i <= n ; i++) s[i] = sigma(i);
		for(int i = 2 ; i <= n ; i++) s[i] = s[i]-i-1;
		long sum = 0;
	      for(int i = 2 ; i <= n ; i++) sum += s[i];
	      System.out.println(sum * 4);
	}
}


from math import ceil
k , d , t = [int(x) for x  in input().split()]

n = ceil(k/d)*d
diff = n - k
new_k = k+(diff/2)
res = (t//new_k)*n
if t%new_k <= k :
    res += t%new_k
else :
    res += k+(t%new_k- k)*2
print(res)

import java.io.*;
import java.util.*;
public class CF936_D1_A{
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);

		long k=sc.nextLong();
		long d=sc.nextLong();
		long t=sc.nextLong();

		long total=2*t;

		if(k>=t)
			pw.println(t);
		else{
			long m=(long)Math.ceil(1.0*k/d)*d-k;
			long done=2*k+m;
			long times=total/done;
			double ans=times*(m+k);
			total%=done;
			if(total>=2*k){
				total-=2*k;
				ans+=k;
				ans+=total;
			}else{
				ans+=total/2.0;
			}
			pw.println(ans);
		}

		pw.flush();
		pw.close();
	}

	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {while (st == null || !st.hasMoreElements()) {
			try {st = new StringTokenizer(br.readLine());}
			catch (IOException e) {e.printStackTrace();}}
		return st.nextToken();}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());}
		double nextDouble() {return Double.parseDouble(next());}
		String nextLine(){String str = "";
		try {str = br.readLine();}
		catch (IOException e) {e.printStackTrace();}
		return str;}
	}
}


#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 7;
const int N = 1e5 + 5;
long long n, k;
long long A[N], B[N];
int main() {
  long long i, j, ans = inf, cnt, a = 0, b = 0, l;
  string s, t;
  cin >> s;
  for (i = 0; i < 6; i++) A[i] = s[i] - '0';
  for (i = 0; i < 3; i++) a += A[i];
  for (i = 3; i < 6; i++) b += A[i];
  if (a > b) {
    k = 1;
    swap(a, b);
  }
  multiset<long long> st[2];
  for (i = 3; i < 6; i++) st[1 - k].insert(A[i]);
  for (i = 0; i < 3; i++) st[k].insert(A[i]);
  while (a < b) {
    long long c, d;
    c = *st[0].begin();
    d = *st[1].rbegin();
    if (9 - c > d) {
      a += 9 - c;
      st[0].erase(st[0].begin());
    } else {
      a += d;
      st[1].erase(st[1].find(d));
    }
    ans++;
  }
  cout << ans - inf;
}

def main():
	s = input()
	print(solver(s))

def solver(s):
	L1 = [int(x) for x in s[0:3]]
	L2 = [int(x) for x in s[3:6]]
	diff = sum(L2) - sum(L1)
	if diff == 0:
		return 0
	elif diff < 0:
		L1, L2 = L2, L1
		diff = -diff
	changes = [9 - L1[i] for i in range(3)] + [L2[i] - 0 for i in range(3)]
	changes.sort(reverse = True)
	#print(changes)
	for i in range(6):
		diff -= changes[i]
		if diff <= 0:
			return i + 1

main()

#solver('321456')

#print(solver('000000'))
#print(solver('654321'))
#print(solver('111000'))


import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int l = scan.nextInt();
        int r = scan.nextInt();
        int[] s = new int[100001];
        for(int i=1;i<=n;i++){
            int t=scan.nextInt();
            s[i]=t;
        }
        boolean p = true;
        for(int i=1;i<=n;i++){
            int t=scan.nextInt();
            if(s[i]!=t && (i<l || i>r))
                p=false;
        }

        if(p)System.out.print("TRUTH");
        else System.out.print("LIE");
    }
}

n,l,r = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

if(a[:l - 1] == b[:l - 1] and a[r:] == b[r:]):
    print("TRUTH")
else:
    print("LIE")


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.*;

/*2A*/

public class Main {
	public static void main(String[] args) throws Exception {
		Main mainClass = new Main();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	public String next() throws Exception {
		if (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	public int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	public long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	public Main() throws Exception {
		in = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(new OutputStreamWriter(System.out));

		solve();
		out.close();
	}
	final static double eps = 1e-9;

	static class Point {
		double x, y;
		Point(double _x, double _y) {
			x = _x; y = _y;
		}
		double times(Point o) {
			return this.x * o.y - this.y * o.x;
		}
		double dot(Point o) {
			return x*o.x + y*o.y;
		}
		Point minus(Point o) {
			return new Point(x - o.x, y - o.y);
		}
		double theta() {
			return Math.atan2(y, x);
		}
		double r() {
			return Math.sqrt(x*x + y*y);
		}

	}

	ArrayList<Point> a;
	int n;
	Point P;

	public void solve() throws Exception {
		a = new ArrayList<Point>();
		n = nextInt();
		P = new Point(nextDouble(), nextDouble());
		for (int i = 0 ; i < n ; i ++) {
			Point X = new Point(nextDouble(), nextDouble());
			a.add(X);
		}

		double minDist = 1e30;
		double maxDist = 0.0;

		for (int i = 0 ; i < n ; i ++) {
			Point X = a.get(i), Y = a.get((i + 1) % n);
			double dx = P.minus(X).r();
			double dy = P.minus(Y).r();
			if (minDist > dx || minDist > dy) {
				minDist = Math.min(dx, dy);
			}
			if (maxDist < dx || maxDist < dy) {
				maxDist = Math.max(dx, dy);
			}
			Point XP = P.minus(X);
			Point XY = Y.minus(X);

			Point YP = P.minus(Y);
			Point YX = X.minus(Y);

			if (XP.dot(XY) > 0 && YP.dot(YX) > 0) {
				double d = Math.abs(XP.times(XY)) / XY.r();
				minDist = Math.min(d, minDist);
			}
		}
		double res = Math.PI * (maxDist * maxDist - minDist * minDist);
		out.println(String.format("%.12f", res));
	}
}

import math

def dot(v1, v2):
    return v1[0]*v2[0] + v1[1]*v2[1]

def cross(v1, v2):
    return v1[0]*v2[1] - v1[1]*v2[0]

def mag(x,y):
    return math.sqrt(x**2 + y**2)

def main():
    PI = 3.141592653589793
    mags = []

    n, x0, y0 = map(int, input().split())

    x, y = x0, y0
    for i in range(n):
        x_, y_ = map(int, input().split())
        x_, y_ = x_ - x0, y_ - y0
        if i == 0:
            x1, y1 = x_ , y_
            x, y = x_, y_

        mags.append(mag(x_,y_))

        if dot([x,y],[x-x_, y-y_])*dot([x_,y_],[x_-x,y_-y]) > 0:
            mags.append(abs(cross([x,y],[x_-x,y_-y])) / mag(x-x_,y-y_))

        x, y = x_, y_

    if dot([x,y],[x-x1,y-y1])*dot([x1,y1],[x1-x,y1-y]) > 0:
        mags.append(abs(cross([x,y],[x1-x,y1-y])) / mag(x-x1,y-y1))

    print((max(mags)**2 - min(mags)**2) * PI)

if __name__ == '__main__':
    main()


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws Throwable {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = sc.nexIntArray();
		int ans = 0;
		for(int i = 0; i < n-2;i++)
		{
			if(a[i]!=a[i+1] && a[i+1]!=a[i+2])
			{
				int j = i+2;
				while(j<n)
				{
					if(a[j]!=a[j-1]&&a[j-1]!=a[j-2])++j;
					else break;
				}
				--j;
				int len = j-i+1;
				if(a[i]==a[j])
				{
					ans = Math.max(ans, len/2);
					for (int k = i; k<=j; k++)
						a[k] = a[i];
				}
				else
				{
					ans = Math.max(ans,len/2-1);
					for (int k = i; k<=j; k++)
						a[k] = k-i<len/2? a[i] : a[j];
				}
			}
		}
		System.out.println(ans);
		StringBuilder sb = new StringBuilder();
		for(int i : a)sb.append(i+" ");
		System.out.println(sb);
	}
	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;
		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}
		public Scanner(String file) throws FileNotFoundException { br = new BufferedReader(new FileReader(file));}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public long nextLong() throws IOException {return Long.parseLong(next());}
		public String nextLine() throws IOException {return br.readLine();}
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-'){neg = true;start++;}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else{sb.append(x.charAt(i));if(dec)f *= 10;}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		public int[] nexIntArray() throws Throwable
		{
			st = new StringTokenizer(br.readLine());
			int[] a = new int[st.countTokens()];
			for(int i = 0; i < a.length;i++)a[i]=nextInt();
			return a;
		}
		public boolean ready() throws IOException {return br.ready();}
	}
}

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    flag = 0
    now_begin = 0
    kek = 0
    ans = [[-1] * 2 for i in range(n)]
    for i in range(1, n - 1):
        if a[i] != a[i - 1] and a[i] != a[i + 1]:
            kek += 1
        else:
            flag = max((kek + 1) // 2, flag)
            now_end = i
            if a[now_begin] == a[now_end]:
                ans[now_begin + 1][0] = a[now_begin]
                ans[now_begin + 1][1] = kek
            else:
                ans[now_begin + 1][0] = a[now_begin]
                ans[now_begin + 1][1] = kek // 2
                ans[now_begin + 1 + kek // 2][0] = a[now_end]
                ans[now_begin + 1 + kek // 2][1] = kek // 2
            now_begin = now_end
            kek = 0
    flag = max((kek + 1) // 2, flag)
    print(flag)
    now_end = n - 1
    if a[now_begin] == a[now_end]:
        ans[now_begin + 1][0] = a[now_begin]
        ans[now_begin + 1][1] = kek
    else:
        ans[now_begin + 1][0] = a[now_begin]
        ans[now_begin + 1][1] = kek // 2
        ans[now_begin + 1 + kek // 2][0] = a[now_end]
        ans[now_begin + 1 + kek // 2][1] = kek // 2
    g = 0
    what = 0
    for i in range(n):
        if ans[i].count(-1) != 2:
            what = ans[i][0]
            g = ans[i][1]
        if g <= 0:
            what = a[i]
        a[i] = what
        g -= 1
    for i in range(n):
        a[i] = str(a[i])
    print(' '.join(a))
main()


import java.io.*;
import java.util.*;

public class D {
	static long mod = (long)1e9+7;
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();
		int n = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		List<String> ans = new ArrayList<>();
		int ar[] = sc.readArray(n);
		int countx = 0, county=0;
		for(long i = 0; i<x+1l+y; i++) {
			if(((countx+1.0)/x) > ((county+1.0)/y)) {
				ans.add("Vova");
				county++;
			}else if(((countx+1.0)/x) < ((county+1.0)/y)) {
				ans.add("Vanya");
				countx++;
			}else {
				ans.add("Both");
				ans.add("Both");
				countx++;
				county++;
			}
		}
		for(int i = 0; i<n; i++) {
			System.out.println(ans.get((int)((ar[i]-1)%(0l+x+y))));
		}
	}
	static final Random random = new Random();

	static void sort(int[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			int cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}

	static void sortl(long[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			long cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (st == null  || !st.hasMoreTokens()) {
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
            return Double.parseDouble(next());
        }
	}

}

Vanya
Vanya
Vova
Vova
Vanya
Vova
Vova
Vova
Vanya
Vova

Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya

Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Vanya
Both

Both
Vova
Vanya
Vova
Both
Both
Vova
Vanya
Vova
Both
Both

#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
vector<int> v;
int n, a[maxn], x, y;
string name[3] = {"Vanya", "Vova", "Both"};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> x >> y;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int cntx = 0, cnty = 0;
  while (cntx < x || cnty < y) {
    if ((double)(cntx + 1) / (double)x > (double)(cnty + 1) / (double)y)
      v.push_back(1), ++cnty;
    else if ((double)(cntx + 1) / (double)x < (double)(cnty + 1) / (double)y)
      v.push_back(0), ++cntx;
    else
      v.push_back(2), v.push_back(2), ++cnty, ++cntx;
  }
  for (int i = 0; i < n; ++i) cout << name[v[(a[i] - 1) % (x + y)]] << '\n';
  return 0;
}


/**
 * Created by IntelliJ IDEA.
 * User: shakhov
 * Date: 15.06.2011
 * Time: 15:22:46
 * To change this template use File | Settings | File Templates.
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class CodeForces {

    public void solve() throws IOException {
        int n=nextInt();
        char[] arr=nextToken().toCharArray();
        int tigers=0;
        for(int i=0,l=arr.length;i<l;i++){
            if(arr[i]=='T') tigers++;
        }
        int numbs=0;
        for(int i=0;i<tigers;i++){
            if(arr[i]=='T') numbs++;
        }
        int max=numbs;                                      //HTH
        for(int i=1;i<n;i++){
            int cur=numbs;
            if(arr[i-1]=='T') cur--;
            if(arr[(i+tigers-1)%n]=='T') cur++;
            numbs=cur;
            max=Math.max(max,cur);
        }

        writer.print(tigers-max);
    }

    public static void main(String[] args) {
        new CodeForces().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            //reader = new BufferedReader(new FileReader("LifeWithoutZeros.in"));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            //writer = new PrintWriter(new BufferedWriter(new FileWriter("LifeWithoutZeros.out")));
            //long t=new Date().getTime();
            solve();
            //writer.println(t-new Date().getTime());
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    String nextToken() throws IOException {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(reader.readLine());
        }
        return tokenizer.nextToken();
    }
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string t, s;
  cin >> n >> s;
  t = s;
  sort(s.begin(), s.end());
  int ret = (1 << 21);
  for (int i = 0; i < s.length() + 1; i++) {
    int dif = 0;
    for (int i = 0; i < s.length(); i++) {
      if (t[i] != s[i]) dif++;
    }
    ret = min(ret, dif);
    rotate(s.begin(), s.begin() + 1, s.end());
  }
  cout << ret / 2 << endl;
}


import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class C {

	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

    static void exit() {
    	sc.close();
    	out.close();
    	System.exit(0);
    }

    public static void main(String[] args) {
    	long a = sc.nextLong();
    	long b = sc.nextLong();
    	if(b <= 1) {
    		out.println(a*a-b*b);
    		while(a>0) {
    			a--;
    			out.print('o');
    		}
    		while(b>0) {
    			b--;
    			out.print('x');
    		}
    		out.println();
    		exit();
    	}
    	if(a == 0) {
    		out.println(-b*b);
    		out.println(build('x', b));
    		exit();
    	}
    	long max_score = Long.MIN_VALUE;
    	int best_ga = 0;
    	int best_gb = 0;
    	for(int gb = 1; gb <= Math.min(a+1, b); gb++) {
    		long rem = b % gb;
    		long base = b / gb;
    		long lose = rem * (base+1)*(base+1) + (gb-rem)*base*base;

    		int ga = Math.max(1, gb-1);
    		long gain = (a-ga+1)*(a-ga+1) + ga-1;
    		//out.println(gain+" "+lose);
    		if(max_score < gain-lose) {
    			max_score = gain-lose;
    			best_ga = ga;
    			best_gb = gb;
    		}
    	}
    	out.println(max_score);
    	long remb = b % best_gb;
    	long baseb = b / best_gb;
    	ArrayList<String> a_list = new ArrayList<>(best_ga);
    	ArrayList<String> b_list = new ArrayList<>(best_gb);
    	a_list.add(build('o', a-best_ga+1));
    	for(int i = 2; i <= best_ga; i++) {
    		a_list.add("o");
    	}
    	for(int i = 1; i <= best_gb; i++) {
    		if(i <= remb) {
    			b_list.add(build('x',baseb+1));
    		} else {
    			b_list.add(build('x',baseb));
    		}
    	}
    	int i = 0;
    	for(i = 0; i < best_ga; i++) {
    		out.print(b_list.get(i)+a_list.get(i));
    	}
    	while(i < best_gb) {
    		out.print(b_list.get(i));
    		i++;
    	}
    	out.println();
        exit();
    }
    static String build(char c, long n) {
    	StringBuilder s = new StringBuilder(""+c);
    	for(int i = 2; i <= n; i++) s.append(""+c);
    	return s.toString();
    }
}

a, b = map(int, input().split())
sx = lambda p: (a - p + 1) ** 2 + p - 1
sy = lambda q: (b % q) * (1 + b // q) ** 2 + (b // q) ** 2 * (q - b % q)
n = min(a, b)

if a == 0:
    print( -b ** 2)
    print( b * "x" )

elif b <= 1:
    print( a ** 2 - b ** 2 )
    print ( a * "o" + b * "x" )

else:
    res = - (a + b) ** 2
    for p in range(1, n + 1):
        for q in range(p-1, p+2):
            if(1 <= q <= b):
                pos = sx( p )
                neg = sy( q )
                if res < pos - neg:
                    res = pos - neg
                    res_p = p
                    res_q = q
    print( res )

    s = ""
    if res_p >= res_q:
        for i in range(res_p):
            wl = 1 if i > 0 else a - (res_p-1)
            s += wl * "x"
            ll = b // res_q + 1 if i < b % res_q else b // res_q
            if i < res_q: s += ll * "o"
    else:
        for i in range(res_q):
            ll = b // res_q + 1 if i < b % res_q else b // res_q;
            s += ll * "x"
            wl = 1 if i > 0 else a - (res_p-1)
            if i < res_p: s+= wl * "o"
    print( s )


n, t = int(input()), list(map(int, input().split()))
a, b = {}, {}
for i, j in enumerate(t):
    if not j in a: a[j] = i
    else: b[j] = i
p = [(a[j], b[j] - 1) for j in b]
s = [j if j > 0 else 0 for j in t]
u = v = 2 * t[p[0][0]] - 1
for i in range(n - 1): s[i + 1] += s[i]
for i, j in p:
    u = 2 * t[i] + s[j] - s[i]
    if u > v: a, b, v = i, j, u
s = list(range(1, a + 1)) + [i for i, j in enumerate(t[a + 1: b + 1], a + 2) if j < 0] + list(range(b + 3, n + 1))
print(v, len(s))
print(' '.join(map(str, s)))

import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import java.text.*;
public class Rough{

    static PrintWriter w=new PrintWriter(System.out);
    public static void main(String [] args){
        DecimalFormat dm=new DecimalFormat("0.000000");
        Scanner sc=new Scanner(System.in);
        TreeMap<Integer,ArrayList<Integer>> map=new TreeMap<Integer,ArrayList<Integer>>();
        int n=sc.nextInt();
        int arr[]=new int[n+1];
        for(int i=1;i<=n;i++){
            arr[i]=sc.nextInt();
        }

        long pSum[]=new long[n+2];
        long bSum[]=new long[n+2];
        for(int i=1;i<=n;i++){
            if(arr[i]<0){
                pSum[i]=pSum[i-1];
            }
            else{
                pSum[i]=pSum[i-1]+(long)arr[i];
            }
        }
        for(int i=n;i>=1;i--){
            if(arr[i]<0){
                bSum[i]=bSum[i+1];
            }
            else{
                bSum[i]=bSum[i+1]+(long)arr[i];
            }
        }
        for(int i=1;i<=n;i++){
            if(map.containsKey(arr[i])){
                ArrayList<Integer> a=map.get(arr[i]);
                a.add(i);
                map.replace(arr[i],a);
            }
            else{
                ArrayList<Integer> t=new ArrayList<Integer>();
                t.add(i);
                map.put(arr[i],t);
            }
        }
//        for(Integer i:map.keySet()){
//            System.out.println(i+" "+map.get(i));
//        }
        long sum=pSum[n];
        int in1=0,in2=0;
        long max=Long.MIN_VALUE;
        for(Integer i:map.keySet()){
            ArrayList<Integer> temp=map.get(i);
            if(temp.size()>=2){
                int a=temp.get(0);
                int b=temp.get(temp.size()-1);
                long total=sum-(pSum[a-1]+bSum[b+1]);
                if(i<0){
                    total=total+(long)(2*i);
                }
                if(total>max){
                    max=total;
                    in1=a;
                    in2=b;
                }
            }
        }
        System.out.print(max+" ");
        int count=0;
        for(int i=in1+1;i<in2;i++){
            if(arr[i]<0){
                count++;
            }
        }
        System.out.println(in1-1+n-in2+count);
        for(int i=1;i<in1;i++){
            w.print(i+" ");
        }
        for(int i=in1+1;i<in2;i++){
            if(arr[i]<0){
                w.print(i+" ");
            }
        }
        for(int i=in2+1;i<=n;i++){
            w.print(i+" ");
        }
        w.println();
        w.close();
    }
}


#include <bits/stdc++.h>
using namespace std;
int n, arr[100], i, j;
bool a[100][100];
bool Ok(int x, int y) {
  while (x && y) {
    int a = x % 10;
    int b = y % 10;
    x /= 10;
    y /= 10;
    if (a && b) return false;
  }
  return true;
}
int main() {
  cin >> n;
  vector<vector<int> > v;
  for (int i = 0; i < n; i++) cin >> arr[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (Ok(arr[i], arr[j])) a[i][j] = true;
  for (int i = 0; i < n; i++) {
    bool b = false;
    for (int j = 0; j < v.size(); j++) {
      int k;
      for (k = 0; k < v[j].size(); k++) {
        if (!a[i][v[j][k]]) break;
      }
      if (k == v[j].size()) v[j].push_back(i), b = true;
    }
    if (!b) v.push_back(vector<int>(1, i));
  }
  for (i = 0, j = 1; j < v.size(); j++)
    if (v[i].size() < v[j].size()) i = j;
  cout << v[i].size() << endl;
  for (j = 0; j < v[i].size(); j++) cout << arr[v[i][j]] << " ";
  return 0;
}

n = int(input())
arr = list(map(int,input().split()))
t = []
flag = 0
if(0 in arr):
    t.append(0)
if(100 in arr):
    t.append(100)
for i in range(n):
    if(arr[i]>0 and arr[i]<10):
        t.append(arr[i])
        flag = 1
        break
for i in range(n):
    if(arr[i]%10 == 0 and arr[i]>0 and arr[i]<100):
        t.append(arr[i])
        flag = 1
        break
if(flag==0):
    for i in range(n):
        if(arr[i]>10 and arr[i]<100):
            t.append(arr[i])
            break
print(len(t))
for i in range(len(t)):
    print(t[i],end = " ")


import java.io.*;
import java.util.*;

public class CF259B {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int[][] aa = new int[3][3];
		for (int i = 0; i < 3; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			for (int j = 0; j < 3; j++)
				aa[i][j] = Integer.parseInt(st.nextToken());
		}
		int xpy = aa[0][2] + aa[2][0];
		int xmy = aa[1][2] - aa[0][1];
		int x = (xpy + xmy) / 2;
		int y = (xpy - xmy) / 2;
		aa[0][0] = x;
		aa[2][2] = y;
		aa[1][1] = aa[0][0] + aa[0][1] + aa[0][2] - aa[1][0] - aa[1][2];
		for (int i = 0; i < 3; i++)
			System.out.println(aa[i][0] + " " + aa[i][1] + " " + aa[i][2]);
	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
	public static void main(String args[]) throws Exception{
		Scanner s=new Scanner(System.in);
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer st=new StringTokenizer(br.readLine());
		PrintStream out=System.out;
		StringBuilder sb=new StringBuilder();
		int n=s.nextInt();
		int a[][]=new int[n][2];
		int k=s.nextInt();
		for(int i=0;i<n;i++){
			for(int j=0;j<2;j++)
				a[i][j]=s.nextInt();
		}
		Arrays.sort(a,new Comparator<int []>(){

			@Override
			public int compare(int[] arg0, int[] arg1) {
				// TODO Auto-generated method stub
				if(arg0[0]==arg1[0]){
					return Integer.compare(arg0[1], arg1[1]);
				}
				else{
					return Integer.compare(arg1[0], arg0[0]);
				}
			}

		});
		//for(int i=0;i<n;i++){
			//	System.out.println(a[i][0]+" "+a[i][1]);
		//}
		int[] b=new int[n];
		int rank=1,groups=1;
		for(int i=0;i<n;i++){
			int j;
			for( j=i;(j+1<n) && (a[j][0]==a[j+1][0] && a[j][1]==a[j+1][1]) ;j++){
				rank++;
				groups++;
			}
			//System.out.println(groups);
			int x=j;
			for(;j>=i;j--){
				b[j]=groups;

			}
			i=x;
			groups=1;

		}
		System.out.println(b[k-1]);
		br.close();
		out.flush();
		out.close();
	}
}

n, k = map(int, input().split())
table =[]
table_dic = dict()

for i in range(n):
    p, t = map(int, input().split())
    table_dic[i + 1] = [p,t]
    table.append([p, 50 - t])

ranking = sorted(table, key=lambda table: (table[0], table[1]), reverse=True)
for i in range(n):
    ranking[i][1] = 50 - ranking[i][1]

counter = 0
for i in range(n):
    if ranking[k - 1] == table_dic[i + 1]:
        counter += 1
print(counter)


#include <bits/stdc++.h>
using namespace std;
int main() {
  int vp, vd, t, f, c;
  scanf("%d %d %d %d %d", &vp, &vd, &t, &f, &c);
  int kol = 0;
  if (vp < vd) {
    double t0 = c;
    t0 /= vp;
    double T = vp * t;
    T /= vd - vp;
    double x = t;
    while (x + T < t0) {
      kol++;
      x = x + 2 * T + f;
      T = vp * x;
      T /= vd - vp;
    }
  }
  printf("%d", kol);
  return 0;
}

vp = int(input())
vd = int(input())
t = int(input())
f = int(input())
c = int(input())
distance = t * vp
time = t
treasure = 0
if vp == vd:
    if t == 0:
        print(1)
    else:
        print(0)
elif vp > vd:
    print(0)
else:
    while distance < c:
        timeadd = distance/(vd - vp)
        distance += vp * timeadd
        if distance >= c:
            break
        else:
            time += timeadd
            treasure += 1
            timeadd = f + distance/vd
            distance += timeadd * vp
    print(treasure)


def solve(arr,n):
    arr.sort()
    names = [x[1] for x in arr]
    counts = [x[0] for x in arr]

    segments = []
    curr_count = counts[0]
    curr_len = 0
    L = 0
    for i in range(n):
        if counts[i]==curr_count:
            curr_len += 1
        else:
            segments.append((L,i-1))
            L = i
            curr_count = counts[i]
            curr_len = 1
    segments.append((L,n-1))

    h = [1 for i in range(n)]
    tall_dudes = 0
    for j in range(len(segments)):
        segment = segments[j]
        L,R = segment
        for i in range(L-1,-1,-1):
            if tall_dudes < counts[L] and h[i]==1:
                h[i] = 10**9-j
                tall_dudes += 1
        if tall_dudes < counts[L]:
            print(-1)
            return
    for i in range(n):
        print(names[i],h[i])

n = int(input())
a = []
for i in range(n):
    x = input().split()
    a.append((int(x[1]),x[0]))
solve(a,n)

36
ehsz 3
og 7
uzi 9
raqkfkyvo 29
u 34
k 28
zoukn 33
z 11
ljkd 5
zqveo 29
foftv 32
e 1
tv 34
s 3
tkyacr 20
emhtosyne 1
rto 7
noxv 23
sw 6
wisywcj 6
mjjkdgwwth 2
wbjfux 1
dubrh 4
rttidtex 2
rprbjlsjy 9
mmc 0
ofy 28
pvirnjc 14
ffdycmsbri 4
hn 3
ggwb 0
liscspwpag 19
hetvq 31
ee 4
wuuysoaqqc 10
huhhsdc 1

23
fgtxkw 4
qgbokh 0
frb 0
nninr 10
bczzdfvjkh 1
uxpelsmxxq 2
ntvvx 2
ardaae 0
ctetnl 0
hgk 0
vmwo 18
ojaubfibf 1
nu 7
gbixtuotft 4
ekmjrgxylj 1
avcygg 1
mxgdulijf 1
otjmjmvpz 3
xzubpxqnj 14
lowoz 3
mnfg 4
o 15
m 1

5
gnaczgg 2
zokbxiahao 4
b 0
nljumplxkn 4
fyclu 1

50
q 0
a 0
z 0
w 0
s 0
x 0
e 0
d 0
c 0
r 0
f 0
v 0
t 0
g 0
b 0
y 0
h 0
n 0
u 0
j 0
m 0
i 0
k 0
o 0
l 0
p 0
qq 0
aa 0
zz 0
ww 0
ss 0
xx 0
ee 0
dd 0
cc 0
rr 0
ff 0
vv 0
tt 0
gg 0
bb 0
ii 0
kk 0
ll 0
yy 0
hh 0
nn 0
uu 0
jjjjj 3
mm 0

9
kyywkcoaw 8
owxo 1
zvjjqlre 0
dlwnpxp 2
kytj 4
ba 7
dppua 6
bf 3
nuis 5

ardaae 1
ctetnl 2
frb 3
hgk 4
qgbokh 23
avcygg 6
bczzdfvjkh 7
ekmjrgxylj 10
m 11
mxgdulijf 12
ojaubfibf 22
ntvvx 14
uxpelsmxxq 21
lowoz 15
otjmjmvpz 20
fgtxkw 17
gbixtuotft 18
mnfg 19
nu 16
nninr 13
xzubpxqnj 9
o 8
vmwo 5

zvjjqlre 9
owxo 8
dlwnpxp 7
bf 6
kytj 5
nuis 4
dppua 3
ba 2
kyywkcoaw 1

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, nop, i, j, k, l, a, temp;
  char b[100];
  string stt[3010];
  vector<pair<int, string> > vct;
  vector<int> v2, v3;
  cin >> n;
  nop = n;
  for (i = 0; i < n; i++) {
    cin >> stt[i] >> a;
    vct.push_back(make_pair(a, stt[i]));
    v2.push_back(i);
  }
  v2.push_back(n);
  sort(vct.begin(), vct.end());
  for (i = 0; i < n; i++) {
    if (vct[i].first > i) {
      cout << -1 << endl;
      return 0;
    }
  }
  int nn = n;
  for (i = nn - 1; i >= 0; i--) {
    if (vct[i].first != 0) {
      temp = v2[n - vct[i].first];
      v3.push_back(temp);
      v2.erase(v2.begin() + n - vct[i].first);
      n--;
    }
  }
  if (v2.empty() == 0) {
    nn = v2.size();
    for (i = nn - 1; i > 0; i--) v3.push_back(v2[i]);
  }
  for (i = nop - 1, j = 0; i >= 0; j++, i--) {
    cout << vct[nop - i - 1].second << " " << v3[i] << endl;
  }
  return 0;
}


//package codeforces.D666;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.StringTokenizer;

/**
 * @author muhossain
 * @since 2020-08-14
 */

public class C {

    public static void main(String[] args) {
        FastReader fs = new FastReader();

        int n = fs.nextInt();
        int[] nums = new int[n + 1];

        for (int i = 0; i < n; i++) {
            nums[i] = fs.nextInt();
        }

        StringBuilder output = new StringBuilder();

        output.append(1).append(" ").append(n).append("\n");

        for (int i = 0; i < n; i++) {
            output.append(BigInteger.valueOf(-1).multiply(BigInteger.valueOf(nums[i]).multiply(BigInteger.valueOf(n))));

            if (i != n - 1) {
                output.append(" ");
            }
        }

        output.append("\n");

        if (n == 1) {
            output.append(1).append(" ").append(1).append("\n");
            output.append(0).append("\n");

            output.append(1).append(" ").append(1).append("\n");
            output.append(0);
        } else {
            output.append(1).append(" ").append(n - 1).append("\n");

            for (int i = 0; i < n - 1; i++) {
                output.append(BigInteger.valueOf(nums[i]).multiply(BigInteger.valueOf(n - 1)));

                if (i != n - 2) {
                    output.append(" ");
                }
            }

            output.append("\n");
            output.append(n).append(" ").append(n).append("\n");
            output.append(BigInteger.valueOf(nums[n - 1]).multiply(BigInteger.valueOf(n - 1)));
        }

        System.out.println(output);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public static FastReader getFileReader(String fileName) throws FileNotFoundException {
            return new FastReader(new InputStreamReader(new FileInputStream(new File(fileName))));
        }

        public static FastReader getDefaultReader() throws FileNotFoundException {
            return new FastReader();
        }

        public FastReader(InputStreamReader inputStreamReader) {
            br = new BufferedReader(inputStreamReader);
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

n=int(input());vals=list(map(int,input().split()))
if n>=2:
    print(1,n)
    ans=[-i*n for i in vals]
    print(*ans)
    print(2,n)
    a1=[i*(n-1) for i in vals[1:n]]
    print(*a1)
    print(1,1)
    print(vals[0]*(n-1))
else:
    print(1,1)
    print(-vals[0])
    print(1,1)
    print(0)
    print(1,1)
    print(0)


import java.io.*;
import java.util.*;

public class game{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int t = scan.nextInt();
        for(int i = 0; i<t; i++){
            String s =scan.next();
            int count1 = 0;
            int count0 = 0;
            int count = 0;
            for(int j = 0; j<s.length(); j++){
                if(s.charAt(j) == '0'){
                    count0++;
                }
                if(s.charAt(j) == '1'){
                    count1++;
                }
            }
            if(count1>count0){
                count = count0;
            }else{
                count = count1;
            }

            // for(int j = 1; j<s.length(); j++){
            //     if(s.charAt(j) == '1' && s.charAt(j-1) == '0'){
            //         count++;
            //     }
            //     if(s.charAt(j) == '0' && s.charAt(j-1) == '1'){
            //         count++;
            //     }
            //     if(j>2){
            //         if(s.charAt(j) == '1' && s.charAt(j-3) == '0'){
            //             if(s.charAt(j-1) == '1' && s.charAt(j-2) == '0'){
            //                 count++;
            //             }

            //         }
            //         if(s.charAt(j) == '0' && s.charAt(j-3) == '1'){
            //             if(s.charAt(j-1) == '0' && s.charAt(j-2) == '1'){
            //                 count++;
            //           }
            //         }
            //     }
            //     if(j>2){
            //         if(s.charAt(j) == '0' && s.charAt(j-1) == '0' && s.charAt(j-2) == '1' && s.charAt(j-3) == '0'){
            //             count--;
            //         }
            //         if(s.charAt(j) == '1' && s.charAt(j-1) == '0' && s.charAt(j-2) == '1' && s.charAt(j-3) == '1'){
            //             count--;
            //         }
            //     }
            // }
            if(count%2 == 0){
                System.out.println("NET");
            }else{
                System.out.println("DA");
            }
        }
    }
}

NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET
NET

#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, zer, jed, x;
  cin >> t;
  string s;
  for (int i = 0; i < t; i++) {
    cin >> s;
    zer = 0;
    jed = 0;
    for (int j = 0; j < s.size(); j++) {
      switch (s[j]) {
        case '0':
          zer++;
          break;
        case '1':
          jed++;
          break;
      }
    }
    if (zer <= jed) {
      x = zer;
    } else {
      x = jed;
    }
    if (x % 2 == 1) {
      cout << "DA" << endl;
    } else {
      cout << "NET" << endl;
    }
  }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class TVSubscriptions {
	public static void main(String[] args) throws IOException {
		InputReader r = new InputReader(System.in);
		int t = r.nextInt();
		BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
		while (t-- > 0) {
			int x = solve(r);
			out.append(x + "\n");
		}
		out.flush();
		out.close();
	}

	static int[] cnt = new int[1000005];

	private static int solve(TVSubscriptions.InputReader r) {
		int n = r.nextInt();
		int k = r.nextInt();
		int d = r.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = r.nextInt();
		}
		int curr = 0;
		for (int i = 0; i < d; i++) {
			cnt[arr[i]]++;
			if (cnt[arr[i]] == 1)
				curr++;
		}
		int res = curr;
		for (int i = d; i < n; i++) {
			cnt[arr[i - d]]--;
			if (cnt[arr[i - d]] == 0)
				curr--;
			cnt[arr[i]]++;
			if (cnt[arr[i]] == 1)
				curr++;
			res = Math.min(res, curr);
		}
		for (int i = n - d; i < n; i++)
			cnt[arr[i]]--;
		return res;

	}

	static class InputReader {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream));
			tokenizer = null;
		}

		public InputReader(FileReader stream) {
			reader = new BufferedReader(stream);
			tokenizer = null;
		}

		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 1e9 + 5;
const double PI = acos(-1);
const int X[] = {1, -1, 0, 0};
const int Y[] = {0, 0, 1, -1};
const int mod = 1e9 + 7;
int t, n, k, d;
map<int, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> k >> d;
    int a[n + 5];
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    int cnt = 0;
    for (int i = 1; i <= d; i++) {
      if (!mp[a[i]]) {
        ++cnt;
      }
      mp[a[i]]++;
    }
    int l = 1, ans = cnt;
    for (int i = d + 1; i <= n; i++) {
      mp[a[l]]--;
      if (mp[a[l]] == 0) {
        --cnt;
      }
      ++l;
      if (!mp[a[i]]) {
        ++cnt;
      }
      mp[a[i]]++;
      ans = min(ans, cnt);
    }
    cout << ans << "\n";
    mp.clear();
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 5, M = 3e3 + 5;
const long long inf = 1e18 + 100, mod = 1e9 + 7;
const double eps = 1e-9;
long long pos[N];
pair<long long, long long> a[N];
map<long long, long long> b;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, m, k;
  cin >> n >> m >> k;
  for (long long i = 1; i <= n; ++i) cin >> a[i].first;
  for (long long i = 1; i <= n; ++i) cin >> a[i].second;
  for (long long i = 1; i <= n; ++i)
    if (a[i].first > b[a[i].second]) b[a[i].second] = a[i].first;
  long long cnt = 0;
  while (k--) {
    long long i;
    cin >> i;
    if (b[a[i].second] != a[i].first) cnt++;
  }
  cout << cnt;
  return 0;
}

n,m,k=map(int,input().split())
p=list(map(int,input().split()))
s=list(map(int,input().split()))
c=set(map(int,input().split()))
d={}
for i in range(n):
    if s[i] not in d:
        d[s[i]]=[-1]
    if p[i]>d[s[i]][0]:
        d[s[i]]=(p[i],i)
st=set()
for i in d:
    st.add(d[i][1]+1)
#print(c,st)
c=c.difference(st)
print(len(c))


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.InputStream;

public class Main {

    public static void main(String[] args) throws IOException {
//    	File file1 = new File("C:/Users/hasee/Desktop/std.in");
//    	File file3 = new File("C:/Users/hasee/Desktop/std.out");
//    	File file2 = new File("C:/Users/hasee/Desktop/2.txt");
//    	InputStream inputStream = new FileInputStream(file1);
//    	InputStream inputStream1 = new FileInputStream(file3);
//    	OutputStream outputStream = new FileOutputStream(file2);
    	InputStream inputStream = System.in;
    	OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {

        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {

        	int a = in.nextInt();
        	int sum = in.nextInt();
        	int b = in.nextInt();
        	int t = 0;
        	int ans = 0;
        	for(int n=0;n<a;n++){
        		int x = in.nextInt();
        		int y = in.nextInt();
        		ans += (x - t)/b;
        		t = x+y;
        	}
        	ans += (sum - t)/b;
        	System.out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
        	return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

class Node{
	int l,r,t;
}

n,l,a = map(int,input().split())
b =[]
for i in range(n):
	b.append([int(e) for e in input().split()])
ans = 0
for i in range(n-1):
	ans += (b[i+1][0] - b[i][1] - b[i][0])//a
if(n > 0):
	ans += b[0][0]//a
	ans += (l - b[n-1][1] - b[n-1][0])//a
else:
	ans += l//a
print(ans)


n,k = list(map(int,input().split()))

data = sorted(list(input()))

data = list(map(lambda x:ord(x)-ord('a')+1,data))

result = 0
used = 0
idx =0
prev = -2

# print(data)

for d in data:
    if d > prev+1:
        result+= d
        prev = d
        used += 1

    if used == k:
        break

if used < k:
    print(-1)
else:
    print(result)

import java.util.*;
import java.io.*;
public class A
{
	public static void main (String[] args)
	{
		Scanner s=new Scanner(System.in);
		int N=s.nextInt();
		int K=s.nextInt();
		s.nextLine();
		char C1[]=s.nextLine().toCharArray();

		Arrays.sort(C1);
		int L1=C1.length;

		String S=""+C1[0];
		for(int i=1;i<L1;i++)
		{
		    if(C1[i]!=C1[i-1])
		    S=S+C1[i];
		}

	//	System.out.println(S);

		char C2[]=S.toCharArray();
		int L2=C2.length;

		if(K>L2)
		{
			System.out.println(-1);
		}
		else
		{
		List<Integer> L=new ArrayList<Integer>();

		for(int j=0;j<=L2-K;j++)
		{
		int a=C2[j]-'a'+1;
		int c=1,k=j;

		for(int i=j;i<L2;i++)
		{
		   if(C2[i]-C2[k]>1)
		   {
			   k=i;
		       a+=C2[i]-'a'+1;
		       c++;
		   }
		   if(c==K)
		   {
			   L.add(a);
			   break;
		   }
		}
		}

	//	System.out.println(L);
		if(L.size()!=0)
		{
			Collections.sort(L);
			System.out.println(L.get(0));
		}
		else
		System.out.println(-1);
		}

	}}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int s, v1, v2, t1, t2;
  cin >> s >> v1 >> v2 >> t1 >> t2;
  int st = s * v1 + t1 * 2, nd = s * v2 + t2 * 2;
  if (st < nd) {
    cout << "First";
  } else if (st > nd) {
    cout << "Second";
  } else {
    cout << "Friendship";
  }
  return 0;
}

Second Second First First Second Second First First Second Second First First Second Second Friendship Second First First Second First First First First First First Second Friendship Second Second First First Second Second Second Friendship Second First Second Second Second First Friendship First Second First First First First Second Friendship Second Second First Second First Second Second Friendship

import java.util.*;
public class Main{
    public static void main(String[]args){

        Scanner sc=new Scanner(System.in);
		//System.out.println("s");
		int s=sc.nextInt();
		int v1=sc.nextInt();
		int v2=sc.nextInt();
		int t1=sc.nextInt();
		int t2=sc.nextInt();
		int val1=(s*v1)+2*t1;
		int val2=(s*v2)+2*t2;
		String result="Friendship";
		if(val1<val2){
			result="First";
		}else if(val2<val1){
			result="Second";
		}
       System.out.println(result);

    }}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int[] f = new int[n + 1];
            for (int i = 1; i <= n; i++) f[i] = in.nextInt();
            boolean[] ok = new boolean[n + 1];
            for (int i = 1; i <= n; i++) {
                if (f[i] == i) {
                    ok[i] = true;
                }
            }
            for (int i = 1; i <= n; i++) {
                if (!ok[f[i]]) {
                    out.println(-1);
                    return;
                }
            }
            int count = 0;
            int[] label = new int[n + 1];
            int idx = 1;
            ArrayList<Integer> x = new ArrayList<>();
            for (int i = 1; i <= n; i++) {
                if (ok[i]) {
                    count++;
                    label[i] = idx++;
                    x.add(i);
                }
            }
            out.println(count);
            for (int i = 1; i <= n; i++) {
                if (i != 1) out.print(" ");
                out.print(label[f[i]]);
            }
            out.println();
            for (int j = 0; j < x.size(); j++) {
                if (j != 0) out.print(" ");
                out.print(x.get(j));
            }
            out.println();
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println() {
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void print(int i) {
            writer.print(i);
        }

        public void println(int i) {
            writer.println(i);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

#include <bits/stdc++.h>
#pragma warning(disable : 4996)
const int kMaxn = 100010;
int n, m, a[kMaxn], g[kMaxn], h[kMaxn];
int main() {
  static int i, j, k, x, now, ans;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) scanf("%d", a + i);
  m = 0;
  memset(g, 0, sizeof(g));
  memset(h, 0, sizeof(h));
  for (i = 1; i <= n; ++i) {
    if (!g[i]) {
      if (g[a[i]]) {
        g[i] = g[a[i]];
      } else {
        g[i] = g[a[i]] = ++m;
        h[m] = a[i];
      }
    }
  }
  ans = 0;
  for (i = 1; i <= n; ++i)
    if (h[g[i]] != a[i]) ans = -1;
  for (i = 1; i <= m; ++i)
    if (g[h[i]] != i) ans = -1;
  if (ans == -1) {
    puts("-1");
    return 0;
  }
  printf("%d\n", m);
  for (i = 1; i <= n; ++i) printf("%d ", g[i]);
  puts("");
  for (i = 1; i <= m; ++i) printf("%d ", h[i]);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
long long t[2222];
long long p1[5555];
long long p2[20000];
int main() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> t[i];
  }
  sort(t, t + n);
  for (long long i = 0; i < n; ++i) {
    for (long long j = i + 1; j < n; ++j) {
      p1[t[j] - t[i]]++;
    }
  }
  for (long long i = 0; i < 5555; ++i) {
    for (long long j = 0; j < 5555; ++j) {
      p2[i + j] += p1[i] * p1[j];
    }
  }
  long double ans = 0;
  long double q = 0;
  for (int i = 1; i < 5555; ++i) {
    q += p2[i - 1];
    ans += p1[i] * q;
  }
  ans /= (long double)n * (n - 1) * n * (n - 1) * n * (n - 1) / 8;
  cout << fixed << setprecision(15) << ans << '\n';
}

import java.util.*;
public class JerrysProtest
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);

		int n = in.nextInt();

		int[] array = new int[n];
		for(int x = 0; x < n; x++)
		{
			array[x] = in.nextInt();
		}

		Arrays.sort(array);

		long[] freq = new long[5000];
		for(int y = 0; y < array.length; y++)
		{
			for(int z = y + 1; z < array.length; z++)
			{
				freq[array[z] - array[y]]++;
			}
		}

		long[] sum = new long[freq.length + 1];
		for(int a = freq.length - 1; a >= 0; a--)
		{
			sum[a] = sum[a + 1] + freq[a];
		}

		long count = 0;
		for(int a = 0; a < freq.length; a++)
		{
			for(int b = 0; b < freq.length; b++)
			{
				if(a + b < 5000)
				{
					count += freq[a] * freq[b] * sum[a + b + 1];
				}
			}
		}

		long total = (n * (n - 1)) / 2;
		total = total * total * total;

		System.out.println((double)count / total);
	}
}


import java.util.Scanner;

public class ez {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int[] time = new int[5];
		int[] wrong = new int[5];
		for(int i = 0; i < 5; i++){
			time[i]=in.nextInt();
		}
		for(int i = 0; i < 5; i++){
			wrong[i]=in.nextInt();
		}
		double score =0;
		for(int i = 0; i < 5; i++){
			int value = 500+500*(i);
			score+=Math.max(.3*value, (1-(time[i]/250.0))*value-50*wrong[i]);
		}
		score+=100*in.nextInt();
		score-=50*in.nextInt();
		System.out.println((long)Math.round(score));
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class B {

	public static void main(String[] args)throws Exception {
		long r=in();
		long x=in();
		long y=in();
		long x1=in();
		long y1=in();
		double d=Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1));
		if (d==0 || d-0<0.00000001){
			System.out.println(0);
			return;
		}
		//System.out.println(d);
		int k=0;
		while (d>=4*r || d-4*r<0.00000001 && d-4*r>-0.00000001){
		//	System.out.println(d);
			k++;
			d-=2*r;
		}
k+=d==2*r||(d-2*r<0.00000001 && d-2*r>-0.00000001)|| d<2*r?1:2;
System.out.println(k);
	}
	static BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;
	static int in() throws IOException{
		if (st==null || !st.hasMoreTokens()){
			st=new StringTokenizer(buf.readLine());
		}
		return Integer.parseInt(st.nextToken());
	}
	static long ll() throws IOException{
		if (st==null || !st.hasMoreTokens()){
			st=new StringTokenizer(buf.readLine());
		}
		return Long.parseLong(st.nextToken());
	}
	static String str() throws IOException{
		if (st==null || !st.hasMoreTokens()){
			st=new StringTokenizer(buf.readLine());
		}
		return (st.nextToken());
	}
		static double dub() throws IOException{
			if (st==null || !st.hasMoreTokens()){
				st=new StringTokenizer(buf.readLine());
			}
			return Double.parseDouble(st.nextToken());
	}
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int r, x, y, x1, y1;
  cin >> r >> x >> y >> x1 >> y1;
  int ans;
  ans = ceil(sqrt(pow(x - x1, 2) + pow(y - y1, 2)) / (2 * r));
  cout << ans;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  long cn1, cn2, x, y;
  cin >> cn1 >> cn2 >> x >> y;
  int lo = 1, hi = 0x7FFFFFFF, mid;
  while (lo < hi) {
    mid = lo + (hi - lo) / 2;
    int rex = mid - (mid / x);
    int rey = mid - (mid / y);
    int total = mid - (mid / (x * y));
    if (cn1 <= rex && cn2 <= rey && (cn1 + cn2) <= total)
      hi = mid;
    else
      lo = mid + 1;
  }
  cout << hi << endl;
  return 0;
}

c1,c2,x,y=map(int,input().split())
def fn(val):
    f=[val//x,val//y]
    both=val//(x*y)
    f=[i-both for i in f]
    oth=val-f[0]-f[1]-both
    cnt=[c1-f[1],c2-f[0]]
    if cnt[0]<0:cnt[0]=0
    if cnt[1] < 0: cnt[1] = 0
    return (sum(cnt)<=oth)
l=0;r=int(1e18)
while r-l>1:
    m=(r+l)//2
    if fn(m):
        r=m
    else:l=m
print(r)


import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * #
 * @author pttrung
 */
public class B_Round_39 {

    public static long MOD = 1000000007;
    static int[] X = {0, 1, 0, -1, 1, -1, -1, 1};
    static int[] Y = {1, 0, -1, 0, 1, -1, 1, -1};

    public static void main(String[] args) throws FileNotFoundException {
        // PrintWriter out = new PrintWriter(new FileOutputStream(new File(
        // "output.txt")));
        PrintWriter out = new PrintWriter(System.out);
        Scanner in = new Scanner();
        int n = in.nextInt();
        int m = in.nextInt();
        int k = in.nextInt();

        int result = 0;
        int cur = 1;
        while (n > 0 && m > 0) {
            if (cur == k) {
                break;
            }
            n -= 2;
            m -= 2;
            cur++;
        }
        if (cur < k || n <= 0 || m <= 0) {
            out.println(0);
        } else {
            out.println(cal(n, m));
        }

        out.close();
    }

    static int cal(int n, int m) {
        int result = (n * m + 1) / 2;
        if (n > 2 && m > 2) {
            result -= ((n - 2) * (m - 2) + 1) / 2;
        }
        return result;
    }

    public static int[] KMP(String val) {
        int i = 0;
        int j = -1;
        int[] result = new int[val.length() + 1];
        result[0] = -1;
        while (i < val.length()) {
            while (j >= 0 && val.charAt(j) != val.charAt(i)) {
                j = result[j];
            }
            j++;
            i++;
            result[i] = j;
        }
        return result;

    }

    public static boolean nextPer(int[] data) {
        int i = data.length - 1;
        while (i > 0 && data[i] < data[i - 1]) {
            i--;
        }
        if (i == 0) {
            return false;
        }
        int j = data.length - 1;
        while (data[j] < data[i - 1]) {
            j--;
        }
        int temp = data[i - 1];
        data[i - 1] = data[j];
        data[j] = temp;
        Arrays.sort(data, i, data.length);
        return true;
    }

    public static int digit(long n) {
        int result = 0;
        while (n > 0) {
            n /= 10;
            result++;
        }
        return result;
    }

    public static double dist(long a, long b, long x, long y) {
        double val = (b - a) * (b - a) + (x - y) * (x - y);
        val = Math.sqrt(val);
        double other = x * x + a * a;
        other = Math.sqrt(other);
        return val + other;

    }

    public static class Point implements Comparable<Point> {

        int x, y;

        public Point(int start, int end) {
            this.x = start;
            this.y = end;
        }

        @Override
        public int hashCode() {
            int hash = 5;
            hash = 47 * hash + this.x;
            hash = 47 * hash + this.y;
            return hash;
        }

        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final Point other = (Point) obj;
            if (this.x != other.x) {
                return false;
            }
            if (this.y != other.y) {
                return false;
            }
            return true;
        }

        @Override
        public String toString() {
            return "Point{" + "x=" + x + ", y=" + y + '}';
        }

        @Override
        public int compareTo(Point o) {
            return x - o.x;
        }
    }

    public static class FT {

        long[] data;

        FT(int n) {
            data = new long[n];
        }

        public void update(int index, long value) {
            while (index < data.length) {
                data[index] += value;
                index += (index & (-index));
            }
        }

        public long get(int index) {
            long result = 0;
            while (index > 0) {
                result += data[index];
                index -= (index & (-index));
            }
            return result;

        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    public static long pow(long a, long b, long MOD) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        long val = pow(a, b / 2, MOD);
        if (b % 2 == 0) {
            return val * val % MOD;
        } else {
            return val * (val * a % MOD) % MOD;

        }
    }

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() throws FileNotFoundException {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
            //  br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("input.txt"))));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
int perimeter(int w, int h) {
  if (w == 1) return h;
  if (h == 1) return w;
  return 2 * w + 2 * (h - 2);
}
int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int res = 0;
  while (true) {
    int border = (perimeter(n, m) + 1) / 2;
    --x;
    if (!x) {
      res = border;
      break;
    }
    n -= 2;
    m -= 2;
    if (n <= 0 || m <= 0) {
      break;
    }
  }
  cout << res << endl;
  fclose(stdin);
  fclose(stdout);
  return 0;
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Blinds {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String temp[] = br.readLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int l = Integer.parseInt(temp[1]);
		int number=0;
		int lengths[] = new int[n];

		temp = br.readLine().split(" ");
		for (int i=0;i<lengths.length;i++)
			lengths[i] = Integer.parseInt(temp[i]);

		int ans=0;
		Arrays.sort(lengths);
		for (int k=l;k<=lengths[lengths.length-1];k++) {
			number=0;
			for (int i=0;i<lengths.length;i++) {
				number+= (lengths[i]/k);
			}
			ans = Math.max(ans, number*k);
		}
		System.out.println(ans);
	}
}

m, l = map(int, input().split())
a = list(map(int, input().split()))
print(max(i * sum(ai // i for ai in a) for i in range(l, 101)))


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Stack;

public class alternating {
	public static void main(String[] args) throws Throwable {
		BufferedReader bf = new BufferedReader(new InputStreamReader (System.in));
		PrintWriter pw = new PrintWriter(System.out, true);
		String inp=bf.readLine();
		Stack<Character> st = new Stack<Character>();
		for(int i=0;i!=inp.length();i++)
		{
			if(st.size()!=0&&st.peek()==inp.charAt(i))
				st.pop();
			else
				st.push(inp.charAt(i));
		}
		if(st.size()==0)
			System.out.print("YES");
		else
			pw.print("NO");
		pw.close();
	}
}

No No No No No No No No No No No No No No No No No No No Yes No No No Yes No Yes No No No No No No No No No No No No No No No No No No No Yes No No No No No No No No

#include <bits/stdc++.h>
using namespace std;
const int INF = ~(1 << 31);
const double eps = 1e-6;
const long double PI = 3.1415926535;
const int MOD = 1e9 + 7;
int n, m;
int main() {
  string s;
  cin >> s;
  stack<int> st;
  for (int(i) = 0; (i) < (s.size()); ++(i)) {
    int g = s[i] == '+';
    if (st.size() && st.top() == g)
      st.pop();
    else
      st.push(g);
  }
  if (st.size() == 0)
    puts("Yes");
  else
    puts("No");
  return 0;
}


import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Niyaz Nigmatullin
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		FastPrinter out = new FastPrinter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
//        test();
        int n = in.nextInt();
        int m = in.nextInt();
        out.println(solve(n, m));
//        if (solve(n, m) != solveStupid(n, m)) {
//            throw new AssertionError();
//        }
    }

    static final int MOD = 1000000007;

    static int solve(int n, int m) {
        int[][] dp = new int[m][n + 1];
        int[][] dp2 = new int[m][n + 1];
        dp[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            int s = 0;
            int ss = 0;
            dp[0][i] = 1;
            for (int j = 1; j < m; j++) {
                dp2[j][i] = (ss + s + 1) % MOD;
                s += dp[j][i - 1];
                if (s >= MOD) {
                    s -= MOD;
                }
                ss += s;
                if (ss >= MOD) {
                    ss -= MOD;
                }
                dp[j][i] = (ss + 1) % MOD;
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            int cur = 0;
            for (int j = 1; j < m; j++) {
                cur = (int) ((cur + (long) dp[j][i + 1] * dp2[j][n - i] % MOD * (m - j)) % MOD);
            }
            ans += cur;
            if (ans >= MOD) {
                ans -= MOD;
            }
        }
        return ans;
    }

    }

class FastScanner extends BufferedReader {

    boolean isEOF;

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
            if (isEOF && ret < 0) {
                throw new InputMismatchException();
            }
            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (c >= 0 && !isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

    }

class FastPrinter extends PrintWriter {

    public FastPrinter(OutputStream out) {
        super(out);
    }

    public FastPrinter(Writer out) {
        super(out);
    }

}


import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Sequence {

	public static void main(String[] args) throws NumberFormatException, IOException {
		int[] dp = new int[100];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		StringTokenizer st = new StringTokenizer(br.readLine());
		int cur, cnt;
		for(int i = 0; i < n; i++) {
			cnt = 0;
			cur = Integer.parseInt(st.nextToken());
			while(cur != 0) {
				while( cur % 2 == 0 ) cur /= 2;
				cur--;
				cnt++;
			}
			dp[cnt]++;
		}
		BigInteger ans = new BigInteger("0");
		for(int i = 0; i < 100; i++) {
			if(dp[i] == 0) continue;
			BigInteger aux = new BigInteger(dp[i]+"");
			ans = ans.add(aux.multiply(aux.subtract(BigInteger.ONE)).divide(BigInteger.ONE.add(BigInteger.ONE)));
		}
		System.out.println(ans);

	}

}

#include <bits/stdc++.h>
using namespace std;
vector<int> f(100001);
int comp(int i) {
  int b = 0, d = 0;
  while (i > 0) {
    if (i & 1 == 1) b++;
    i = i >> 1;
  }
  return b;
}
int main() {
  int m, i, n;
  int h[65];
  long long j, s;
  for (i = 0; i < 65; i += 2) {
    h[i] = 0;
    h[i + 1] = 0;
  }
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> f[i];
  }
  for (i = 0; i < n; i++) {
    h[comp(f[i])]++;
  }
  s = 0;
  for (i = 0; i < 65; i++) {
    j = h[i];
    j = j * (j - 1);
    j = j / 2;
    s += j;
  }
  cout << s;
  return 0;
}


//package round138;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class C {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int n = ni(), K = ni();
		int mod = 1000000007;
		int[] v = new int[n];
		for(int i = 0;i < n;i++)v[n-1-i] = ni();

		int[] a = new int[n];
		Arrays.fill(a, 1);

		int[] ret = pow(a, v, K, mod);
		for(int i = 0;i < n;i++){
			out.println(ret[n-1-i]);
		}
	}

	// int行列*ベクトル
	public static int[] mul(int[] A, int[] v, int mod)
	{
		int m = A.length;
		int n = v.length;
		int[] w = new int[m];
		for(int i = 0;i < m;i++){
			long sum = 0;
			for(int k = i;k < n;k++){
				sum += (long)A[k-i] * v[k];
				sum %= mod;
			}
			w[i] = (int)sum;
		}
		return w;
	}

	// A^e*v
	public static int[] pow(int[] A, int[] v, long e, int mod)
	{
		int[] MUL = A;
		for(int i = 0;i < v.length;i++)v[i] %= mod;
		for(;e > 0;e>>>=1) {
			if((e&1)==1)v = mul(MUL, v, mod);
			MUL = p2tu(MUL, mod);
		}
		return v;
	}

	static int[] p2tu(int[] A, int mod)
	{
		int n = A.length;
		int[] C = new int[n];
		for(int i = 0;i < n;i++){
			long sum = 0;
			for(int j = 0;j <= i;j++){
				sum += (long)A[j] * A[i-j];
				sum %= mod;
			}
			C[i] = (int)sum;
		}
		return C;
	}

	public static int[][] p2tu(int[][] A, int mod)
	{
		int n = A.length;
		int[][] C = new int[n][n];
		for(int i = 0;i < n;i++){
			long sum = 0;
			for(int j = 0;j <= i;j++){
				sum += (long)A[0][j] * A[0][i-j];
				sum %= mod;
			}
			for(int j = i;j < n;j++){
				C[j-i][j] = (int)sum;
			}
		}
		return C;
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new C().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}

#include <bits/stdc++.h>
using namespace std;
int const mod = 1e9 + 7;
int const maxn = 2005;
inline void safe_mul(int& a, int b) { a = (a * 1LL * b) % mod; }
inline int mypow(int a, int b) {
  int ans = 1;
  int tmp = a;
  while (b) {
    if (b & 1) safe_mul(ans, tmp);
    safe_mul(tmp, tmp);
    b >>= 1;
  }
  return ans;
}
inline int inv(int x) { return mypow(x, mod - 2); }
int koef[maxn];
int a[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  koef[0] = 1;
  for (int i = 1; i < n; ++i) {
    koef[i] = koef[i - 1];
    safe_mul(koef[i], (k + i - 1) * 1LL * inv(i) % mod);
  }
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) {
    int ans = 0;
    for (int j = 0; j <= i; ++j) ans = (ans + koef[j] * 1LL * a[i - j]) % mod;
    cout << ans << " \n"[i == n - 1];
  }
  return 0;
}


n=int(input())
ar=[float('inf')]*(n+1)
ar[0]=0
for i in range(n):
    t,c=map(int,input().split())
    for j in range(n-1,-1,-1):
        w=min(j+t+1,n)
        ar[w]=min(ar[w],ar[j]+c)
print(ar[n])

import java.io.*;
import java.util.*;
public class Answer19B{
    public static void main(String[] args){
	BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
	new Kai(reader).solve();
    }
}
class Kai{
    BufferedReader reader;
    public Kai(BufferedReader reader){
	this.reader=reader;
    }
    public void solve(){
	//TODO
	int n=to_i(read());
	int[] t=new int[n];
	long[] c=new long[n];
	long sum=0;
	for(int i=0;i<n;i++){
	    String[] tmp=read().split(" ");
	    t[i]=to_i(tmp[0]);
	    c[i]=to_i(tmp[1]);
	    sum+=c[i];
	}
	long[][] dp =new long[n+1][n+1+n];
	for(int i=0;i<n+1;i++)Arrays.fill(dp[i],-1);
	dp[0][n]=0;
	for(int i=0;i<n;i++){
	    for(int j=0;j<2*n+1;j++){
		if(dp[i][j]!=-1){
		    //get
		    dp[i+1][j-1]=Math.max(dp[i][j]+c[i],dp[i+1][j-1]);
		    //remove
		    int num=j+t[i];
		    if(num>=2*n)num=2*n;
		    dp[i+1][num]=Math.max(dp[i][j],dp[i+1][num]);
		}
	    }
	}
	long max=0;
	for(int i=n;i<2*n;i++){
	    max=Math.max(dp[n][i],max);
	}
	println(sum-max);
    }
    public String read(){
	String s=null;
	try{
	    s=reader.readLine();
	}catch(IOException e){
	    e.printStackTrace();
	}
	return s;
    }
    public int to_i(String s){
	return Integer.parseInt(s);
    }
    public long to_l(String s){
	return Long.parseLong(s);
    }
    public void print(Object s){
	System.out.print(s);
    }
    public void println(Object s){
	System.out.println(s);
    }
    public void debug(Object s){
	System.err.print(s);
    }
    public void debugln(Object s){
	System.err.println(s);
    }
    public void debug(Object[] s){
	System.err.print(Arrays.deepToString(s));
    }
    public void debugln(Object[] s){
	System.err.print(Arrays.deepToString(s));
    }
}


#include <bits/stdc++.h>
int main() {
  int A[31][31];
  int n, i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) scanf("%d", &A[i][j]);
  int result = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) {
      int column = 0;
      int c = 0;
      for (; c < n; c++) column += A[c][j];
      int row = 0;
      int r = 0;
      for (; r < n; r++) row += A[i][r];
      if (column > row) result++;
    }
  printf("%d", result);
  return 0;
}

n = int(input())
r = lambda : list(map(int, input().split()))
arr = []
for i in range(n):
    a = r()
    arr.append(a)

row = [sum(i) for i in arr]

col = []
for i in range(n):
    c = 0
    for j in range(n): c+=arr[j][i]
    col.append(c)

ans = 0
for i in range(n):
    for j in range(n):
        if row[i] < col[j]: ans+=1

print(ans)


import math
t=int(input())
for i in range(t):
    a,b=map(int,input().split())
    m=min(a,b,(a+b)/3)
    print(math.floor(m))

import java.util.Scanner;

public class Main {

	public static void main(String[] args)

	{
		Scanner scan = new Scanner(System.in);
		int t = scan.nextInt();
		while(t-->0)
		{
			long X = scan.nextInt(), Y= scan.nextInt();
			long a = Math.max(X, Y), b = Math.min(X, Y);
			if(a==b)System.out.println(Math.max((a-1-(a-1)/3),0));
			else if(a>=2*b)System.out.println(b);
			else System.out.println(((2*b-a)-1-((2*b-a)-1)/3)+(a-b));
		}
	}

}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int t, c;
  vector<int> T(N - 1);
  vector<int> C(N - 1);
  cin >> t;
  int a = t;
  for (int i = 0; i < N - 1; i++) {
    int b;
    cin >> b;
    T[i] = abs(b - a);
    a = b;
  }
  cin >> c;
  int w = c;
  for (int i = 0; i < N - 1; i++) {
    int b;
    cin >> b;
    C[i] = abs(w - b);
    w = b;
  }
  if (c != t || a != w) {
    cout << "No";
  } else {
    sort(T.begin(), T.end());
    sort(C.begin(), C.end());
    for (int i = 0; i < N - 1; i++) {
      if (C[i] != T[i]) {
        cout << "No";
        return 0;
      }
    }
    cout << "Yes";
  }
  return 0;
}

No No No No No No No No No No No Yes No Yes No No No No Yes No Yes No No Yes No No No Yes No Yes No No No Yes Yes No No No No No

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ReaderFastIO in = new ReaderFastIO(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EMagicStones solver = new EMagicStones();
        solver.solve(1, in, out);
        out.close();
    }

    static class EMagicStones {
        public void solve(int testNumber, ReaderFastIO in, PrintWriter out) {

            int n = in.nextInt();
            int[] c = in.readArrayInt(n);
            int[] t = in.readArrayInt(n);
            int[] dc = new int[n - 1];
            int[] dt = new int[n - 1];

            for (int i = 1; i < n; i++) {
                dc[i - 1] = Math.abs(c[i] - c[i - 1]);
                dt[i - 1] = Math.abs(t[i] - t[i - 1]);
            }

            ContestUtils.shuffle(dc);
            ContestUtils.shuffle(dt);
            Arrays.sort(dc);
            Arrays.sort(dt);

            out.println(c[0] == t[0] && c[n - 1] == t[n - 1] && Arrays.equals(dc, dt) ? "Yes" : "No");

        }

    }

    static class ReaderFastIO {
        BufferedReader br;
        StringTokenizer st;

        public ReaderFastIO() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public ReaderFastIO(InputStream input) {
            br = new BufferedReader(new InputStreamReader(input));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] readArrayInt(int n) {

            int[] array = new int[n];

            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }

            return array;
        }

    }

    static class ContestUtils {
        public static int[] shuffle(int[] array) {

            Random rgen = new Random();

            for (int i = 0; i < array.length; i++) {
                int randomPosition = rgen.nextInt(array.length);
                int temp = array[i];
                array[i] = array[randomPosition];
                array[randomPosition] = temp;
            }

            return array;
        }

    }
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int n;
  cin >> n;
  int g1 = 0, g2 = 0;
  int a[n / 2];
  for (int i = 0; i < n / 2; i++) {
    cin >> a[i];
  }
  sort(a, a + n / 2);
  for (int i = 1; i <= n / 2; i++) {
    g1 += abs(a[i - 1] - (i * 2 - 1));
  }
  for (int i = 1; i <= n / 2; i++) {
    g2 += abs(a[i - 1] - (i * 2));
  }
  cout << min(g1, g2) << endl;
  return 0;
}

import re
import math
import decimal
import bisect

def read():
	return input().strip()

n = int(read())
ps = [0 for i in range(1, n+1)]
nadd = 10
for x in sorted([int(_) for _ in read().split()]):
	ps[x-1] = nadd
	nadd += 10
nadd = 15
for i, p in enumerate(ps):
	if p == 0:
		ps[i] = nadd
		nadd += 10

# print(ps)
swapped = True
swapsA = 0
workps = ps[:]
while swapped:
	swapped = False
	for i in range(n-1):
		if workps[i] > workps[i+1]:
			tmp = workps[i]
			workps[i] = workps[i+1]
			workps[i+1] = tmp
			swapsA += 1
			swapped = True
# print(ps, swapsA)

for i, p in enumerate(ps):
	if p % 10 == 5:
		ps[i] -= 10

swapped = True
swapsB = 0
workps = ps[:]
while swapped:
	swapped = False
	for i in range(n-1):
		if workps[i] > workps[i+1]:
			tmp = workps[i]
			workps[i] = workps[i+1]
			workps[i+1] = tmp
			swapsB += 1
			swapped = True

# print(ps, swapsB)
print(min(swapsA, swapsB))