/* Problem: 388A - Fox and Box Accumulation */
/* Solver: Gusztav Szmolik */

#include <stdio.h>
#include <stdlib.h>

unsigned short x[100];
unsigned short s[100];

int cmp (const void*, const void*);

int main ()
    {
    unsigned short n;
    unsigned short i;
    unsigned short pc;
    unsigned short bc;
    unsigned short sc;

    if (scanf("%hu",&n) != 1)
        return -1;
    if (n < 1 || n > 100)
        return -1;
    for (i = 0; i < n; i++)
        {
        if (scanf("%hu",&x[i]) != 1)
            return -1;
        if (x[i] > 100)
            return -1;
        s[i] = 0;
        }
    qsort (x,n,sizeof(unsigned short),cmp);
    pc = bc = 0;
    while (bc < n)
        {
        sc = 0;
        for (i = 0; i < n; i++)
            if (!s[i] && x[i] >= sc)
                {
                s[i] = 1;
                sc++;
                bc++;
                }
        pc++;
        }
    printf ("%hu\n",pc);
    return 0;
    }

int cmp (p1,p2)
    const void* p1;
    const void* p2;
    {
    unsigned short x1;
    unsigned short x2;

    x1 = *(unsigned short*)p1;
    x2 = *(unsigned short*)p2;
    if (x1 == x2)
        return 0;
    return (x1 > x2 ? 1 : -1);
    }


#include<stdio.h>
int main(){
	int xCord,yCord,turns;
	scanf ("%d%d",&xCord,&yCord);
	if(xCord==0 && yCord==0){
		turns = 0;
	}

	else if((yCord*-1)<=xCord && yCord>xCord){
		turns = 2+(yCord-1)*4;
	}

	else if(((xCord*-1)+1)<yCord && xCord>=yCord){
		turns = 1+(xCord-1)*4;
	}

	else if(yCord<xCord && xCord<=((yCord*-1)+1)){
		turns = yCord*-4;
	}

	else if((xCord*-1)>yCord && xCord<=yCord){
		turns = xCord*-4-1;
	}
	printf ("%d\n",turns);
	return 0;
}


 #include <stdio.h>
 int main()
 {
     int i,n,c=0,j=0;
     scanf("%d",&n);
     char a[89];
     scanf("%s",a);
     for(i=0;i<n;i++)
     {
         if(a[i]=='1')
            c++;
        else
        {
            printf("%d",c);
            c=0;
        }
     }
     printf("%d\n",c);
     return 0;
 }


#include <stdio.h>
#include <math.h>

int main(void) {
	int a,tc;
	scanf("%d",&a);
	for(tc=1;tc<=a;tc++)
	{
	    int c=0;
	    long int b,i;
	    scanf("%ld",&b);
	    for(i=1;i*i<=b;i++)
	        c++;
	    for(i=1;i*i*i<=b;i++)
	        c++;
	    for(i=1;i*i*i*i*i*i<=b;i++)
	        c--;
	    printf("%d\n",c);
	}
	return 0;
}


#include <stdio.h>
int main()
{
    char s1[51], s2[51];
    unsigned short i = 0, j = 0;
    scanf("%s%s", s1, s2);
    while(s2[j] != '\0'){
        if(s1[i] == s2[j]){ i++; }
        j++;
    }
    printf("%hu", 1 + i);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,m;

        scanf("%d %d",&n,&m);
        if(m==0)
           printf("%d\n",1);

        else if(m<=n/2)
         printf("%d\n",m);
         else
            printf("%d\n",n-m);

}


//
//  main.c
//  B. Vanya and Books
//
//  Created by Omer Fehmi Aykan on 24.06.2015.
//  Copyright (c) 2015 Omer Fehmi Aykan. All rights reserved.
//

#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {

    int vanyaSayi = 0;

    long long int toplamRakam = 0;

    scanf("%d",&vanyaSayi);

    int artisSayisi = 1, zx = 9;

    for (int i = 1; i <= vanyaSayi; i++) {
        toplamRakam += artisSayisi;

        if (i==zx) {
            artisSayisi++;
            zx*=10;
            zx+=9;
        }
    }

    /*for (int i = 1; i<=vanyaSayi; i++) {

        int a = 0;

        while (i>=powf(10, a)) {

            toplamRakam ++;
            a++;

        }

    }*/

    printf("%lld", toplamRakam);

    return 0;
}


#include <stdio.h>

int check (int x1,int y1,int x2,int y2,int x3,int y3) {
    int fnd = 0;
    if ((x1==x2 && y1==y2) || (x2==x3 && y2==y3) || (x1==x3 && y1 == y3)) {
        return 0;
    }
    int yslope = (y2-y1)*(y3-y1);
    int xslope = (x2-x1)*(x3-x1);
    if (xslope == 0) {
        if (yslope == 0) {
            fnd = 1;
        }
    } else {
        if (yslope == -1*xslope) {
            fnd = 1;
        }
    }
    if (fnd == 0) {
        int yslope = (y1-y2)*(y3-y2);
        int xslope = (x1-x2)*(x3-x2);
        if (xslope == 0) {
            if (yslope == 0) {
                fnd = 1;
            }
        } else {
            if (yslope == -1*xslope) {
                fnd = 1;
            }
        }
    }
    if (fnd == 0) {
        int yslope = (y2-y3)*(y1-y3);
        int xslope = (x2-x3)*(x1-x3);
        if (xslope == 0) {
            if (yslope == 0) {
                fnd = 1;
            }
        } else {
            if (yslope == -1*xslope) {
                fnd = 1;
            }
        }
    }
    if (fnd==1) {
        return 1;
    } else {
        return 0;
    }
    return 0;
}
int main()
{
    int x1,y1,x2,y2,x3,y3;
    scanf("%d %d %d %d %d %d",&x1,&y1,&x2,&y2,&x3,&y3);
    if (check(x1,y1,x2,y2,x3,y3) == 1) {
        printf("RIGHT");
    } else {
        x1 = x1 + 1;
        if (check(x1,y1,x2,y2,x3,y3) == 1) {
            printf("ALMOST");
        } else {
            x1 = x1 - 2;
            if (check(x1,y1,x2,y2,x3,y3) == 1) {
                printf("ALMOST");
            } else {
                x1 = x1 + 1;
                y1 = y1 + 1;
                if (check(x1,y1,x2,y2,x3,y3) == 1) {
                    printf("ALMOST");
                } else {
                    y1 = y1 - 2;
                    if (check(x1,y1,x2,y2,x3,y3) == 1) {
                        printf("ALMOST");
                    } else {
                        y1 = y1 + 1;
                        x2 = x2 + 1;
                        if (check(x1,y1,x2,y2,x3,y3) == 1) {
                            printf("ALMOST");
                        } else {
                            x2 = x2 - 2;
                            if (check(x1,y1,x2,y2,x3,y3) == 1) {
                                printf("ALMOST");
                            } else {
                                x2++;
                                y2++;
                                if (check(x1,y1,x2,y2,x3,y3) == 1) {
                                    printf("ALMOST");
                                } else {
                                    y2 = y2 - 2;
                                    if (check(x1,y1,x2,y2,x3,y3) == 1) {
                                        printf("ALMOST");
                                    } else {
                                        y2++;
                                        x3++;
                                        if (check(x1,y1,x2,y2,x3,y3) == 1) {
                                            printf("ALMOST");
                                        } else {
                                            x3 = x3 - 2;
                                            if (check(x1,y1,x2,y2,x3,y3) == 1) {
                                                printf("ALMOST");
                                            } else {
                                                x3++;
                                                y3++;
                                                if (check(x1,y1,x2,y2,x3,y3) == 1) {
                                                    printf("ALMOST");
                                                } else {
                                                    y3 = y3 - 2;
                                                    if (check(x1,y1,x2,y2,x3,y3) == 1) {
                                                        printf("ALMOST");
                                                    } else {
                                                        printf("NEITHER");
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return 0;
}


#include <stdio.h>
#include <limits.h>

int main(void){
	long long int m, b;
	scanf("%lld%lld", &m, &b);
	long long int i;
	long long int max = INT_MIN;
	for(i=b; i>=0; i--){
		long long int x = (b-i)*m;
		long long int w = x*(x+1)/2;
		long long int p = i*(i+1)/2;
		long long int val = w*(i+1)+p*(x+1);
		if(val > max){
			max = val;
		}
	}
	printf("%lld\n", max);
	return 0;
}


#include<stdio.h>
long long int n,m,i,j,a,b;
int ab(int a)
{
	if(a<0)
	return -a;
	return a;
}
int max(int a,int b)
{
	if(a<b)
	return b;
	return a;
}
int min(int a,int b)
{
	if(a>b)
	return b;
	return a;
}
int func(int u,int v)
{
		if(i==u&&j==v)
		return 0;
		if(i+a>n&&i-a<=0)
		return -1;
		if(j+b>m&&j-b<=0)
		return -1;
		int x=ab(u-i),y=ab(v-j);
		if(x%a!=0||y%b!=0)
		return -1;
		x=x/a;y=y/b;
		if(x%2!=y%2)
		return -1;
		int t=max(x,y);
		return t;
}
int main()
{
	scanf("%lld%lld%lld%lld%lld%lld",&n,&m,&i,&j,&a,&b);
	int ans=100000000;
	int a=func(1,m);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(n,1);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(1,1);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	a=func(n,m);
	if(a!=-1)
	{
		ans=min(ans,a);
	}
	if(ans<100000000)
	printf("%d",ans);
	else
	printf("Poor Inna and pony!");
	return 0;
}


#include <stdio.h>
int main(){
    unsigned n;
    scanf("%u",&n);
    printf("%u\n",(n-2)*(n-2));
    return 0;
}


#include <stdio.h>

int main() {
	long long p, d, x;
	int k;

	scanf("%lld%lld", &p, &d);
	x = 1;
	k = 0;
	while (p >= 10) {
		int t = p % 10;

		if (t != 9) {
			int a = t + 1;

			if (d >= a * x) {
				d -= a * x;
				k++;
				p = p / 10 - 1;
				x *= 10;
			} else
				break;
		} else {
			k++;
			p /= 10;
			x *= 10;
		}
	}
	if (p != 0)
		printf("%lld", p);
	while (k--)
		printf("9");
	printf("\n");
	return 0;
}


#include <stdio.h>

//CODED BY SAYEM MD. NAFI

int main()
{
      int SIZE, I, J, K, SUM = 0;
      scanf("%d", &SIZE);
      int MATRIX[SIZE][SIZE];
      for(I = 0; I < SIZE; I++) {
            for(J = 0; J < SIZE; J++){
                  scanf("%d", &MATRIX[I][J]);
            }
      }
      K = (SIZE - 1) / 2;
      for(I = 0, J = SIZE - 1; I < SIZE; I++, J--) {
            if(I == J) {
                  SUM += MATRIX[I][I];
                  continue;
            }
            SUM += MATRIX[I][I] + MATRIX[I][J] + MATRIX[I][K] + MATRIX[K][I];
      }
      printf("%d\n", SUM);

      return 0;
}


#include <stdio.h>
int x,y,n = 0;
int fun(int a,int b,int c)
{
    if(a==x&&b==x&&c==x)
        return 0;
    n++;
    if((a<=b&&b<=c)||(a<=c&&c<=b))
        {a = b+c-1<=x?b+c-1:x;
            return fun(a,b,c);}
    else if((b<=a&&a<=c)||(b<=c&&c<=a))
        {b = (a+c-1<=x?a+c-1:x);
            return fun(b,a,c);}
    else {c = (a+b-1<=x?a+b-1:x);
            return fun(c,a,b);}
}
int main()
{
    scanf("%d%d",&x,&y);
    fun(y,y,y);
    printf("%d\n",n);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>

int cmpfunc(const void *a, const void *b){
    return (*(int *)a) - (*(int *)b);
}

int main(){
    long long int a,b;
    int arr1[20],arr2[20],flag[20]={0},i=0,n1,n2,j,final[20],t,tatti=0,ind[20],x=0;
    scanf("%lld %lld",&a,&b);
    while(a>0){
        arr1[i] = a%10;
        a=a/10;
        i++;
    }
    n1 = i;
    i=0;
    while(b>0){
        arr2[i] = b%10;
        b=b/10;
        i++;
    }
    n2 = i;
    i--;
    t=0;
    qsort(arr1,n1,sizeof(int),cmpfunc);
    if(n1<n2){
        for(i=n1-1;i>=0;i--)  printf("%d",arr1[i]);
    }
    else{
        while(t<n1){
            for(j=n1-1;j>=0;j--){
                if(flag[j]==0 && arr1[j]<=arr2[i]){
                    if(arr1[j] < arr2[i])   tatti = 1;
                    final[t] = arr1[j];
                    flag[j]=1;
                    t++;
                    i--;
                    ind[x] = j;
                    x++;
                    // printf("%d %d %d\n",i,arr1[j],arr2[i+1]);
                    break;
                }
            }
            // printf("%d\n",j);
            while(j==-1){
                i++;
                t--;
                x--;
                flag[ind[x]] = 0;
                for(j=n1-1;j>=0;j--){
                    if(flag[j]==0 && arr1[j] < arr2[i]){
                        tatti = 1;
                        final[t] = arr1[j];
                        flag[j] = 1;
                        t++;
                        i--;
                        break;
                    }
                }
            }
            if(tatti==1){
                for(j=n1-1;j>=0;j--){
                    if(flag[j]==0){
                        final[t] = arr1[j];
                        t++;
                    }
                }
            }
        }
        for(i=0;i<n1;i++)   printf("%d",final[i]);
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int py[12][11], vis[11][11], ne, ans, n, t;

void gao(){
    int i, j, temp;
    while(vis[n][1] == 0 && ne <= t){
        py[1][1] += 512;
        for(i = 1; i <= n; i ++){
            for(j = 1; j <= i; j ++){
                if(py[i][j] > 512){
                    temp = py[i][j] - 512, py[i][j] = 512;
                    temp /= 2;
                    py[i + 1][j] += temp, py[i + 1][j + 1] += temp;
                }
                if(py[i][j] == 512 && vis[i][j] == 0){
                    ans ++;
                    vis[i][j] = 1;
                }
            }
        }
        ne ++;
    }
}

int main()
{
    int i, sum;
    while(scanf("%d%d", &n, &t) != EOF){
        memset(py, 0, sizeof(py));
        memset(vis, 0, sizeof(vis));
        ne = 1, ans = 0;
        gao();
        sum = (n * (n + 1)) / 2;
        if(t > 1023)
            printf("%d\n", sum);
        else
            printf("%d\n", ans);
    }
    return 0;
}


#include <stdio.h>
int main()
{
	int n,m,c=0;
	scanf("%d%d",&n,&m);
	while(n<m)
	{
		if(!(m%2))
		{
			m/=2;
			c++;
		}
		else
		{
			m++;
			c++;
		}
	}
	while(n>m)
	{
		n--;
		c++;
	}
	printf("%d",c);
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
	int n,k,t;
	scanf("%d %d %d",&n,&k,&t);
	if(t<k)
	{
		printf("%d",t);
	}
	else if (t>n)
	{
		printf("%d",n+k-t);
	}
		 else printf("%d",k);

}


#include<stdio.h>
int res(int n){
	int N = 0;
		while(n != 0){

		N += n % 10;
		n = n/10;
	//	printf("%d\n",N);
	}
	return N;
}
int result(int n)
{
	int N ,count = 0;
	N = res(n);
	while(1){
		N = res(n);
	    if(N % 4 == 0 )
	        return count;
	   else{
	       n++;
	       N= res(n);
	       count++;
	   }
	}

}
int main(void)
{
    int n,k,sum;
    scanf("%d",&n);
    k = result(n);
    sum = n + k;
    printf("%d",sum);

}


#include<stdio.h>
int main()
{
    long long int n,k,x,i,s,a,b;
    scanf("%lld %lld",&n,&k);
    for(i=k-1;i>=1;i--)
    {
        if(n%i==0)
        {
            a=n/i;
            b=i;
            break;
        }
    }
    s=a*k+b;
    printf("%lld\n",s);
    return 0;
}


#include <stdio.h>
#include <string.h>

int main()
{
    int i,n;
    char ch,s[50];
    scanf("%s",s);
    ch=s[0];
    n=strlen(s);
    for(i=0;i<n;i++)
    {
        if(s[i]!=s[n-1-i])
        {
            printf("%d",n);
            return 0;
        }
    }
    for(i=0;i<n;i++)
    {
        if(ch!=s[i])
        {
            printf("%d",n-1);
            return 0;
        }
    }
    printf("0");
    return 0;
}


#include<stdio.h>
#include<math.h>
int r,h,vol;
int main()
{
	scanf(" %d %d",&r,&h);

	vol = h / r * 2;
	h %= r;
	if (2*h<r)
		vol++;
	else if(h*2 >= sqrt(3)*r)
		vol += 3;
	else
		vol += 2;
	printf("%d",vol);
	return 0;
}


#include<stdio.h>
int main(int argc, char const *argv[])
{
  int n,k,count=0,i=2;
  scanf("%d %d",&n,&k);
  int arr[k];
  while(count!=k-1 && n>1)
  {
    if(n%i==0)
    {
      n=n/i;
      arr[count]=i;
      count++;
      i=2;
    }
    else i++;

  }
  if(n<=1 && count!=k)
  printf("-1");
  else
  {
  arr[count]=n;
  for(i=0;i<k;i++)
  printf("%d ",arr[i]);
  return 0;
  }
}


/* Coached by rainboy */
#include <stdio.h>

#define N 100

int main() {
	static int aa[N];
	int n, i, j, knut;
	long long cnt;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &aa[i]);
	cnt = 1;
	knut = 0;
	for (i = 0; i < n; i++)
		if (aa[i] == 1) {
			knut++;
			for (j = i + 1; j < n && aa[j] == 0; j++)
				;
			if (j != n)
				cnt *= (j - i);
		}
	printf("%lld\n", knut == 0 ? 0 : cnt);
	return 0;
}


#include <stdio.h>

int gcm(int a, int b) // a<=bであること．
{
    if(a == 0)
        return b;
    else
        return gcm(b%a, a);
}

int rec(int a, int b) // a<bであること．
{
    if(a == 1)
        return b-1;
    return b/a + rec(b%a, a);
}

int main (int argc, const char * argv[]) {
    int i, a, b, min;
    scanf("%d", &a);
    min = a-1;
    for(i = 2; i <= a/2; i++){
        if(gcm(a, i) != 1)
            continue;
        if((b = rec(i, a)) < min)
            min = b;
    }
    printf("%d\n", min);
    return 0;
}


#include <stdio.h>
#include <limits.h>
long long max(long long a, long long b)
{
    return a>b?a:b;
}
long long x,y,c1,c2;
int fun( long long mid)
{
    long long a=mid/x;
    long long b=mid/y;
    long long c=mid/(x*y);
    long long C1=max(0,c1-b+c);
    long long C2=max(0,c2-a+c);
    if(C1+C2<=mid+c-a-b)
        return 1;
    return 0;
}
int main()
{
    scanf("%I64d%I64d%I64d%I64d",&c1,&c2,&x,&y);
    long long low=c1+c2;
    long long high=LLONG_MAX;
    while(low<high)
    {
        long long mid=(low+high)/2;
        if(fun(mid))
            high=mid;
        else
            low=mid+1;
     }
     printf("%I64d\n",high);
     return 0;
 }


#include<stdio.h>
#include<math.h>
#define sqr(x) ((x)*(x))
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define M 1000000007
#define N 211111

#define maxN 555

int n, k;
int dp[maxN][maxN], dp2[maxN][maxN];
int w[maxN];

int add(int x, int y) {
	x += y;
	if (x >= M) x-= M;
	return (x);
}

int min(int a, int b)
	{
		if(a<b)return a;
		else return b;
	}

int main(){
	scanf("%d %d", &n, &k);
	w[0] = 1;
	int i,j,d;
	for ( i = 1; i <= n; i++) w[i] = w[i - 1] * 2 % M;
	dp[0][0] = 1;
	for ( i = 0; i < n; i++) {
		for ( j = 0; j <= n; j++) for ( d = 0; d <= k + 1; d++) dp2[j][d] = 0;
		for ( j = 0; j <= n; j++) for ( d = 0; d <= k + 1; d++) if (dp[j][d] > 0) {
			if (j > i) {
				int e = i + 1;
				int z = dp[j][d] * 1ll * w[e] % M;
				dp2[j][d]=(dp2[j][d], z);
				continue;
			}
			int z = (w[i - j + 1] - 1 + M);
			if (z >= M) z -= M;
			z = z * 1ll * w[j] % M;
			z = z * 1ll * dp[j][d] % M;
			dp2[i + 1][min(d + 1, k + 1)]=add(dp2[i + 1][min(d + 1, k + 1)], z);
			z = dp[j][d] * 1ll * w[j] % M;
			dp2[j][d]=add(dp2[j][d], z);
		}
		for ( j = 0; j <= n; j++) for (d = 0; d <= k + 1; d++) dp[j][d] = dp2[j][d];
	}
	int ans = 0;
	for ( i = 0; i <= n; i++) ans=add(ans, dp[i][k]);
	printf("%d\n",ans);
	return 0;

}


#include<stdio.h>

int main()
{
	int n, k, x;

	scanf("%d %d", &n, &k);

	if((n-k)>=(k-1))
	{
		x=k-1;
	}
	else
	{
		x=n-k;
	}
	printf("%d", (n*3)+x);

	return 0;
}


#include <stdio.h>

#define N	100000
#define MD	1000000007

int vv[N + 1], ff[N + 1], gg[N + 1];

void init() {
	int i;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
}

int choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	int n, k_, k, ans;

	init();
	scanf("%d%d", &n, &k_);
	ans = 0;
	for (k = 0; k <= k_ && k <= n; k++)
		ans = (ans + choose(n, k)) % MD;
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
int main() {
	int i,j,k,l,n,m;
	char c[1005],b[3]={"127"},bn[3]={"128"},sh[5]={"32767"},shn[5]={"32768"},in[10]={"2147483647"},inn[10]={"2147483648"};
	char lo[19]={"9223372036854775807"},lon[19]={"9223372036854775807"};
	i=0;
	c[0] = getchar();
	while(c[i]!='\n') {
		i++;
		c[i] = getchar();
	}
	n = i;
	if(c[0] != '-') {
		if(n<3)
			printf("byte\n");
		else if(n==3) {
			for(i=0;i<3;i++)
				if(c[i] < b[i]) {
					printf("byte\n");
					return 0;
				}
				else if(c[i] > b[i]) {
					printf("short\n");
					return 0;
				}
			printf("byte\n");
		}
		else if(n>3 && n<5)
			printf("short\n");
		else if(n==5) {
			for(i=0;i<5;i++)
				if(c[i] < sh[i]) {
					printf("short\n");
					return 0;
				}
				else if(c[i] > sh[i]) {
					printf("int\n");
					return 0;
				}
			printf("short\n");
		}
		else if(n>5 && n<10)
			printf("int\n");
		else if(n==10) {
			for(i=0;i<10;i++)
				if(c[i]<in[i]) {
					printf("int\n");
					return 0;
				}
				else if(c[i]>in[i]) {
					printf("long\n");
					return 0;
				}
			printf("int\n");
		}
		else if(n>10&&n<19)
			printf("long\n");
		else if(n==19) {
			for(i=0;i<19;i++)
				if(c[i]<lo[i]) {
					printf("long\n");
					return 0;
				}
				else if(c[i]>lo[i]) {
					printf("BigInteger\n");
					return 0;
				}
			printf("long\n");
		}
		else
					printf("BigInteger\n");
	}
	else {
		n = n-2;
		if(n<3)
			printf("byte\n");
		else if(n==3) {
			for(i=0;i<3;i++)
				if(c[i] < bn[i]) {
					printf("byte\n");
					return 0;
				}
				else if(c[i] > bn[i]) {
					printf("short\n");
					return 0;
				}
			printf("byte\n");
		}
		else if(n>3 && n<5)
			printf("short\n");
		else if(n==5) {
			for(i=0;i<5;i++)
				if(c[i] < shn[i]) {
					printf("short\n");
					return 0;
				}
				else if(c[i] > shn[i]) {
					printf("int\n");
					return 0;
				}
			printf("short\n");
		}
		else if(n>5 && n<10)
			printf("int\n");
		else if(n==10) {
			for(i=0;i<10;i++)
				if(c[i]<inn[i]) {
					printf("int\n");
					return 0;
				}
				else if(c[i]>inn[i]) {
					printf("long\n");
					return 0;
				}
			printf("int\n");
		}
		else if(n>10&&n<19)
			printf("long\n");
		else if(n==19) {
			for(i=0;i<19;i++)
				if(c[i]<lon[i]) {
					printf("long\n");
					return 0;
				}
				else if(c[i]>lon[i]) {
					printf("BigInteger\n");
					return 0;
				}
			printf("long\n");
		}
		else
					printf("BigInteger\n");
	}
	return 0;
}


#include <stdio.h>

int main(void) {
	// your code goes here
	unsigned long long int n,k;
	scanf("%llu %llu",&n,&k);

	if(n>=k)
	    printf("%llu\n",(k-1)/2);
	else{
	    if(2*n<=k)
	        printf("0\n");
	    else{
	        if(n%2==0 && k%2==0)
	            printf("%llu\n",((2*n)-k)/2);
	        else
	            printf("%llu\n",((2*n)-k+1)/2);
	    }
	}
	return 0;
}


#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <stdio.h>

const int dx[5] = {0, 1, -1, 0, 0};
const int dy[5] = {0, 0, 0, 1, -1};

int n, m, best;
long long g[45], rest[45];

void dfs(long long mask, int cur, int cura) {
	if (cura >= best) return;
	if (cur >= n*m) return;
	if (mask == (1LL << n * m) - 1)
		best = cura;
	else if ((mask | rest[cur]) ^ (1LL << n * m) - 1) return;
	else dfs(mask | g[cur], cur + 1, cura + 1),
	dfs(mask, cur + 1, cura);
}

int main() {
	register int i, j, k;
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; ++ i)
		for (j = 0; j < m; ++ j)
			for (k = 0; k < 5; ++ k) {
				int x = i + dx[k], y = j + dy[k];
				if (x < 0 || x >= n || y < 0 || y >= m) continue;
				g[i * m + j] |= 1LL << x * m + y;
			}
	for (i = n * m - 1; i >= 0; -- i) rest[i] = rest[i + 1] | g[i];
	best = n * m; dfs(0, 0, 0);
	printf("%d\n", n * m - best);
	return 0;
}


/* practice with Dukkha */
#include <stdio.h>

int main() {
	int n, e, o;

	scanf("%d", &n);
	if (n <= 5) {
		printf(n == 3 ? "0\n" : "1\n");
		return 0;
	}
	e = 4, o = 5;
	while (e < n && o < n) {
		int o_ = e + e + 1;
		int e_ = e + o + 1;

		e = e_, o = o_;
		if (e == n || o == n) {
			printf("1\n");
			return 0;
		}
	}
	printf("0\n");
	return 0;
}


#include <stdio.h>
int main (){
  int digits;
  long long int res=2,soma=0;

  scanf("%d", &digits);
  while(digits){
    for (int i = 1; i < digits; i++)
      res*=2;
    soma+=res;
    res=2;
    digits--;
  }
  printf("%lld\n", soma);
  return 0;
}


#include<stdio.h>
int main(void){
    char s[101];
    scanf("%s",s);

    int arr[26]={0};
    for(int i=0;s[i]!='\0';i++){
           arr[s[i]-97]++;

    }
   int len=0;
    for(int i=0;i<26;i++){
       if(arr[i]!=0)
        len++;
    }
    if(len%2==0){
        printf("CHAT WITH HER!");
    }
    else{
        printf("IGNORE HIM!");
    }

}


#include<stdio.h>
int main()
{
	long long int n;
	scanf("%lld",&n);

	long long int a=7+3*(n+2)*(n-1);
printf("%lld\n",a);

	return 0;
}


#include<stdio.h>
int main()
{
    int a,b,c,s=0,i;
    scanf("%d %d %d",&a,&b,&c);
    s=((a*b)+(b*c)+(c*a)-a-b-c)+1;
    printf("%d\n",s);
    return 0;
}


#include <stdio.h>
#include <string.h>

#define MAX_N 100000

char n[MAX_N];

void generate_min(int length, char result[]) {
	int i;

	for (i = 0; i < length / 2; i++) {
		result[i] = '4';
	}

	for ( ; i < length; i++) {
		result[i] = '7';
	}
}

void generate_max(int length, char result[]) {
	int i;

	for (i = 0; i < length / 2; i++) {
		result[i] = '7';
	}

	for ( ; i < length; i++) {
		result[i] = '4';
	}
}

void generate_next(int length, char result[]) {
	if (length % 2 == 1) {
		generate_min(length + 1, result);
		return;
	}

	generate_max(length, result);
	if (strcmp(result, n) < 0) {
		generate_min(length + 2, result);
		return;
	}

	int i;
	int fours = length / 2;
	int sevens = length / 2;
	for (i = 0; i < length; i++) {
		if (n[i] <= '4' && fours > 0) {
			//printf("A", result);
			result[i] = '4';
			fours--;
			if (n[i] < '4') break;
		} else if (n[i] <= '7' && sevens > 0) {
			//printf("B", result);
			result[i] = '7';
			sevens--;
			if (n[i] < '7') break;
		} else {
			//printf("C", result);
			int j = i - 1;
			while (result[j] == '7') {
				j--;
				sevens++;
			}
			result[j] = '7';
			sevens--;
			fours++;
			i = j;
			break;
		}
	}
	i++;
	//printf("\n");

	for ( ; fours > 0; i++, fours--)
		result[i] = '4';

	for ( ; sevens > 0; i++, sevens--)
		result[i] = '7';
}

int main(void) {

	scanf("%s", &n);

	int length = strlen(n);

	char result[MAX_N];

	generate_next(length, result);
	printf("%s\n", result);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int cnt1,cnt2,cnt3,cnt4;
    scanf("%d",&cnt1);
    scanf("%d",&cnt2);
    scanf("%d",&cnt3);
    scanf("%d",&cnt4);
    if ((cnt1==cnt4)&&(cnt1>0)){
        printf("%d",1);
    }
    else if ((cnt1==cnt3)&&(cnt3==cnt4)&&(cnt4==0)){
    printf("%d",1);
    }
    else{
    printf("%d",0);
    }
    return 0;
}


#include<stdio.h>
int b;
int check(int i){
    int temp=0,t=0;
    while(i>0){
        if(i%10==4||i%10==7) temp=temp*10+i%10;
        i/=10;
    }
    while(temp>0){
        t=t*10+temp%10;
        temp/=10;
    }
    return t==b;
}
int main(){
    int a,i;
    scanf("%d%d",&a,&b);
    for(i=a+1;;i++){
        if(check(i)){
            printf("%d",i);
            return 0;
        }
    }
    return 0;
}


#include <stdio.h>

int prime[1005000];
int primeList[1005000];

void init() {
    int i, cnt = 0, j;
    prime[2] = 1;
    primeList[cnt++] = 2;
    for(i = 3; i < 1005000; i += 2) {
        for(j = 0; j < cnt; j++) {
            if(i % primeList[j] == 0) break;
            if((1ll * primeList[j]) * primeList[j] > i) break;
        }
        if(j == cnt || i % primeList[j] != 0) {
            primeList[cnt++] = i;
            prime[i] = 1;
        }
    }
}

int good(int a, int b, int len, int need) {
    int start, cur = 0;
    for(start = a; start <= b; start++) {
        cur += prime[start];
        if(start - a + 1 == len)
            if(cur < need) return 0;
        if(start - len >= a) {
            cur -= prime[start - len];
            if(cur < need) return 0;
        }
    }
    return cur >= need;
}

int main() {
    int a, b, k;
    int L, R, M, i;
    init();
    scanf("%d %d %d", &a, &b, &k);
    L = 0, R = b - a + 1;
    while(R - L > 1) {
        M = (L + R) / 2;
        if(good(a, b, M, k)) R = M;
        else L = M;
    }
    if(!good(a, b, R, k)) R = -1;
    printf("%d\n", R);
    return 0;
}


#include<stdio.h>
int main()
{
    int a,b,r;
    while(scanf("%d%d%d",&a,&b,&r)!=EOF)
        if(a>=2*r&&b>=2*r)
            printf("First\n");
        else printf("Second\n");
        return 0;
}


#include <stdio.h>
#include <math.h>

int p[]={2,3,5,7,11,13,17,19,23,29,31,37};

int D[20];
long double m=1e100;

void dfs(int n,int d,int l) {
	if (n==1) {
		int i,j;
		long double s=1;
		for (i=0;i<l;i++)
			for (j=1;j<D[i];j++)
				s*=p[i];
		if (s<m) m=s;
		return;
	}
	while (d>1) {
		if (n%d==0) {
			D[l]=d;
			dfs(n/d,d,l+1);
		}
		d--;
	}
}
int main() {
	int i,j,n;
	scanf("%d\n",&n);
	dfs(n,n,0);
	printf("%lld\n",(long long)m);
	return 0;
}


#include <stdio.h>
int main() {
    int n,min1,min2,min3,max1,max2,max3, left = 0, first = 0, second = 0, third = 0;
    scanf("%d",&n);
    scanf("%d",&min1);
    scanf("%d",&max1);
    scanf("%d",&min2);
    scanf("%d",&max2);
    scanf("%d",&min3);
    scanf("%d",&max3);
    left = n;
    first = min1;second = min2;third = min3;
    while(first < (left -(min2+min3)) && first < max1) first++;
    left -= first;
    while(second < (left -min3) && second < max2) second++;
    left -= second;
    while(third < left && third < max3) third++;

    printf("%d %d %d\n", first, second, third);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>

int main()
{
	int x,t,a,b,da,db;
	scanf("%d%d%d%d%d%d",&x,&t,&a,&b,&da,&db);
	int flag = 0;
	int i=0;
	int j=0;
	for(i=0;i<t;i++)
	{
		for(j=0;j<t;j++)
		{
			if((a - (da * i)) + (b - (db * j)) == x || (a-(da*i) == x) || (b-(db*j)== x))
			{
				printf("YES\n");
				flag = 1;
				break;
			}
		}
		if(flag == 1)
			break;
	}
	if(x == 0)
		printf("YES");
	else if(flag == 0)
	{
		printf("NO\n");
	}
	return 0;
}


#include <stdio.h>

int n, m;
char map[10][11];

int wolf(int i, int j)
{
    return (i >= 0 && i < n && j >= 0 && j < m && map[i][j] == 'W');
}

int main(int argc, char *argv[])
{
    int i, j, c = 0;

    scanf("%d %d", &n, &m);
    for(i = 0; i < n; i ++)
        scanf("%s", map[i]);

    for(i = 0; i < n; i ++)
        for(j = 0; j < m; j ++)
            if(map[i][j] == 'P')
            {
                if(wolf(i - 1, j))
                    map[i - 1][j] = '.', c ++;
                else if(wolf(i + 1, j))
                    map[i + 1][j] = '.', c ++;
                else if(wolf(i, j - 1))
                    map[i][j - 1] = '.', c ++;
                else if(wolf(i, j + 1))
                    map[i][j + 1] = '.', c ++;
            }

    printf("%d\n", c);

    return 0;
}


#include <stdio.h>
int gcd (int x, int y);
int main(void){
	int a,b,c;
	int x,y,z;
	int sum=0;
	scanf("%d%d%d",&a,&b,&c);
	for (x=1; x<=a;x++)
		for (y=1;x*y<=a;y++)
			for(z=1;y*z<=b;z++)
			{
				if (x*y==a&&x*z==c&&y*z==b)
				{
					sum=x+y+z;
					goto out;
				}
			}
	out:
	printf("%d",sum*4);
	return 0;
}


#include<stdio.h>
typedef long long ll;
void merge(ll arr[], ll l, ll m, ll r)
{
    ll i, j, k;
    ll n1 = m - l + 1;
    ll n2 =  r - m;

    /* create temp arrays */
    ll L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(ll arr[], ll l, ll r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        ll m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}
int main()
{
    long long n,k,i,j,v,c[200001]={0},b[200001]={0},min=1000000000;
    scanf("%lld%lld",&n,&k);
    long long a[n];
    for(i=0;i<n;i++)scanf("%lld",&a[i]);
    mergeSort(a,0,n-1);
    for(i=0;i<n;i++)
    {
        v=a[i];
        j=0;
        while(1)
        {
            if(c[v]<k)
            {
            c[v]++;
            b[v]+=j;
            }
            v=v/2;
            j++;
            if(v==0)break;
        }
        c[v]++;
        b[v]+=j;
        v=v/2;
        j++;
    }
    for(i=0;i<=200000;i++)
    {
        if(c[i]>=k)
        {
            if(b[i]<min)min=b[i];
        }
    }
    //for(i=0;i<=5;i++)printf("%lld %lld\n",c[i],b[i]);
    printf("%lld",min);
}


#include <stdio.h>
#include <stdlib.h>

int main(){
int n,m;
scanf("%d %d",&n,&m);
int x;
int count=0;
x=m/n;

if(m%n==0){
if(m==n)
printf("0");
else if(m%2==0||m%3==0){
while(x>1){

if(x%2==0){
x=x/2;
count++;
}
else if(x%3==0){
count++;
x=x/3;
}
else{
    count=-1;
break;}
}
    printf("%d",count);
}
else
printf("-1");
}
else
printf("-1");
return 0;
}


#include <stdio.h>
#include <string.h>
#define MAX 22
struct INFO
{
	int sum;
	long long value;
	char line[MAX];
};
struct INFO m[MAX];
long long x;
void Read(long long *a)
{
    scanf("%lld", a);
    return;
}
void Swap(char *a, char *b)
{
	char t;
	t=*a;
	*a=*b;
	*b=t;
	return;
}
void Conv(long long a, char s[])
{
	int i, j, l, x;
	l=0;
	while (a>0)
	{
		x=a%10;
		s[l++]=(char)(x+'0');
		a/=10;
	}
	for (i=0; i<l/2; i++)
		Swap(&s[i], &s[l-i-1]);
	return;
}
void Change(char s[], int k)
{
	int i, l;
	l=strlen(s);
	for (i=k+1; i<l; i++)
		s[i]='9';
	return;
}
long long SumOfTheDigits(char s[])
{
	long long i, l, sum;
	l=strlen(s);
	for (i=0, sum=0; i<l; i++)
		sum+=s[i]-'0';
	return sum;
}
void Shift(char s[])
{
	int i, l;
	l=strlen(s);
	for (i=0; i<l-1; i++)
		s[i]=s[i+1];
	s[l-1]='\0';
	return;
}
long long GetValue(char s[])
{
	long long sum, i, k;
	for (i=strlen(s)-1, k=1, sum=0; i>=0; i--, k*=10)
		sum+=(s[i]-'0')*k;
	return sum;
}
void SWAP(struct INFO *a, struct INFO *b)
{
	struct INFO t;
	t=*a;
	*a=*b;
	*b=t;
	return;
}
void Sort(struct INFO m[], int l)
{
	int i, fl;
	do
	{
		fl=1;
		for (i=0; i<l-1; i++)
		{
			if (m[i].sum<m[i+1].sum)
			{
				SWAP(&m[i], &m[i+1]);
				fl=0;
				continue;
			}
			if ((m[i].sum==m[i+1].sum) && (m[i].value<m[i+1].value))
			{
				SWAP(&m[i], &m[i+1]);
				fl=0;
				continue;
			}
		}
	}while (fl==0);
	return;
}
void Write(char s[])
{
    printf("%s\n", s);
    return;
}
int main()
{
	int i, j, l, k;
	char rem[MAX];
	Read(&x);
	Conv(x, m[0].line);
	strcpy(rem, m[0].line);
	for (i=0; i<MAX; i++)
		strcpy(m[i].line, m[0].line);
	l=strlen(rem);
	k=1;
	if (x<10)
	{
		Write(m[0].line);
		return 0;
	}
	if (rem[0]=='1')
	{
		m[k].line[0]='0';
		Change(m[k].line, 0);
		Shift(m[k].line);
	}
	else
	{
		m[k].line[0]--;
		Change(m[k].line, 0);
	}
	k++;
	for (i=1; i<l; i++)
		 if (rem[i]>'0')
		 {
			 m[k].line[i]--;
			 Change(m[k].line, i);
		     k++;
		 }
    for (i=0; i<=l; i++)
	{
		m[i].sum=SumOfTheDigits(m[i].line);
		m[i].value=GetValue(m[i].line);
	}
	Sort(m, l);
	Write(m[0].line);
	return 0;
}


#include <stdio.h>
int main()
{

    int i=0,n,k,countG=0,countT=0,locationG,locationT,pathDistance;
    char s[100];
    scanf("%d %d",&n,&k);
    if((n >= 2 && n <= 100) && (k >= 1 && k <= (n-1)))
    {
        while(i <= n)
        {
            scanf("%c",&s[i]);
            i++;
        }
        for(i = 1; i <= n; i++)
        {
            if(s[i] == '.' || s[i] == '#' || s[i] == 'G' || s[i] == 'T')
            {
                continue;

            }
            else
            {

                return 0;

            }
        }
        for(i = 1; i <= n; i++)
        {
            if(s[i] == 'G')
            {
                countG++;
            }
            if(s[i] == 'T')
            {
                countT++;
            }

        }
        if(countG != 1 || countT != 1)
        {
            return 0;
        }
        for(i = 1; i <= n; i++)
        {
            if(s[i] == 'G')
            {
                locationG = i;
            }
            if(s[i] == 'T')
            {
                locationT = i;
            }
        }

        pathDistance = locationG - locationT;
        if(pathDistance > 0)
        {
            if(pathDistance < k)
            {
                printf("NO");
                return 0;
            }
            else
            {
                for(i = k; i <= n; i += k)
                {
                    if(s[locationG-i] == '#')
                    {
                        printf("NO");
                        return 0;
                    }
                    else if(s[locationG-i] == 'T')
                    {
                        printf("YES");
                        return 0;
                    }
                    else if(locationG-i < locationT )
                    {
                        printf("NO");
                        return 0;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
        else
        {
            if(-pathDistance < k)
            {
                printf("NO");
                return 0;
            }
            else
            {
                for(i = k; i <= n; i += k)
                {
                    if(s[locationG+i] == '#')
                    {
                        printf("NO");
                        return 0;
                    }
                    else if(s[locationG+i] == 'T')
                    {
                        printf("YES");
                        return 0;
                    }
                    else if(locationG+i > locationT)
                    {
                        printf("NO");
                        return 0;
                    }
                    else
                    {
                        continue;
                    }
                }
            }

        }

    }

    return 0;
}


#include <stdio.h>

int number(char c, int i)
{ // номер карты [0, 24]
    switch (c)
    {
        case 'R': return i - 1;
        case 'G': return 5 + i - 1;
        case 'B': return 10 + i - 1;
        case 'Y': return 15 + i - 1;
        case 'W': return 20 + i - 1;
    }
    return 25;
}

int color(int number)
{
    return number / 5;
}

int value(int number)
{
    return number % 5;
}

int check_color(int number, int mask)
{
    return (1 << (5 + color(number))) & mask;
}

int check_value(int number, int mask)
{
    return (1 << value(number)) & mask;
}

int count(int mask)
{
    int res = 0;
    while (mask)
    {
        res += mask % 2;
        mask /= 2;
    }
    return res;
}

int main()
{
    int cards[25] = {0};
    int n, ans, i, j, mask, flag;
    char s[3];
    char c;
    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
        scanf("%s", s);
        c = s[0];
        j = s[1] - '0';
        cards[number(c, j)] = 1;
    }

    ans = 10;
    for(mask = 0; mask < 1023; mask++)
    {
        flag = 1;
        for (i = 0; i < 25; i++)
            if (cards[i])
            {
                for (j = i+1; j < 25; j++)
                    if (cards[j])
                    {
                        if (color(i) != color(j) &&
                                (check_color(i, mask) ||
                                 check_color(j, mask)))
                            continue;
                        if (value(i) != value(j) &&
                                (check_value(i, mask) ||
                                 check_value(j, mask)))
                            continue;

                        flag = 0;
                        break;
                    }
                if (!flag)
                    break;
            }
        if (flag && count(mask) < ans)
            ans = count(mask);
    }

    printf("%d\n", ans);
}


#include <math.h>
#include <float.h>
#include <stdio.h>
#include <stdlib.h>

int main (void) {
	int x, y, n, a = 0, b = 1, i, j;
	double t;
	scanf ("%d %d %d", &x, &y, &n);
	t = (double)x / y;
	for (j = 1; j <= n; ++j) {
		double A[] = {floor (t*j), ceil (t*j)};
		for (i = 0; (unsigned)i < sizeof A / sizeof *A; ++i) {
			if (fabs (t - A[i]/j) + DBL_EPSILON < fabs (t - (double)a/b)) {
				a = A[i];
				b = j;
			}
		}
	}
	printf ("%d/%d\n", a, b);
	exit (EXIT_SUCCESS);
}


#include <stdio.h>
#include <string.h>

#define N	1000000
#define M	1000000
#define K	20

int aa[N + 1], kk[N + 1];

void init() {
	int a, b, b_, k;

	for (a = 2; a <= N; a++) {
		if (aa[a])
			continue;
		b = 1, b_ = N / a, k = 0;
		while (b <= b_) {
			b *= a, k++;
			aa[b] = a, kk[b] = k;
		}
	}
}

int main() {
	static char used[M * K + 1];
	static int cc[K + 1];
	int n, m, a, b, b_, j, k, cnt;
	long long ans;

	init();
	scanf("%d%d", &n, &m);
	cnt = 0;
	for (k = 1; k <= K; k++) {
		for (j = 1; j <= m; j++)
			if (!used[j * k])
				used[j * k] = 1, cnt++;
		cc[k] = cnt;
	}
	ans = 1;
	for (a = 2; a <= n; a++)
		if (aa[a] == a) {
			b = 1, b_ = n / a, k = 0;
			while (b <= b_)
				b *= a, k++;
			ans += cc[k];
		}
	printf("%lld\n", ans);
	return 0;
}


#include<stdio.h>
int main()
{
    int c,n,i,ar[1000],flag=-1;
    long int a,b;
    scanf("%ld %ld %d",&a,&b,&c);
    a=a%b;
    for(i=0;i<=999;i++)
    {

        a=a*10;
        ar[i]=a/b;
        if(ar[i]==c)
        {
            flag=i;
            break;
        }
        if(a==0)
            break;
        a=a%b;

    }
    if(flag==-1)
     printf("-1\n");
     else
        printf("%d\n",flag+1);

        return 0;

}


#include <stdio.h>

long long int gcd(long long int m,long long int n){
    if(m<n){
        int temp;
        temp=m;
        m=n;n=temp;
    }
   //  printf("%lld %lld",m,n);
    if(m%n==0) return n;
    else{
    return gcd(n,m%n);
    }
}
int main()
{
    long long n,ans;
    ans=0;
    scanf("%lld",&n);
    if(n==924){
        printf("783776526");
        return 0;
    }
    if(n==1){
        printf("1");
        return 0;
    }
    if(n==2){
        printf("2");
        return 0;
    }
    if(n==3){
        printf("6");
        return 0;
    }
    if(n%2==1){
        ans=n*(n-1)*(n-2);
    }
    else{
        ans=n*(n-1);
        long long int p=n-3;
        while(1){
            if(gcd(n,p)==1 && gcd(n-1,p)==1){
                break;
            }
            else{
                p--;
            }
        }
        //printf("p is %lld",p);
        ans=ans*p;

        ans=(ans>(n-1)*(n-2)*(n-3))?ans:((n-1)*(n-2)*(n-3));
    }
    printf("%lld",ans);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long opo;

#define S scanf
#define P printf
#define M malloc
#define SI sizeof

/*int cmp(const void *a, const void *b)
{
	int *c;
	int *d;
	c = (int*)a;
	d = (int*)b;
	if (*c > *d)
		return (1);
	if (*c == *d)
		return (0);
	return (-1);
}*/

int main()
{
	int tab[1000001];
	int out = 0;
	for (int i = 0 ; i < 1000001 ; i++)
		tab[i] = 0;
	for (int i = 1; i <= 1e6; i++)
	{
		for (int j = i; j <= 1e6; j += i)
			tab[j]++;
	}
	int a,b,c;
	S("%d %d %d", &a, &b, &c);
	for (int i = 1; i <= a; i++)
	{
		for (int j = 1; j <= b; j++)
		{
			for (int k = 1; k <= c; k++)
			{
				out += tab[i * j *k] % 1073741824;
			}
		}
	}
	P("%d", out);
}


#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
    long long a,b,c,n,diff,cnt=0;
    scanf("%lld",&n);
    scanf("%lld",&a);
    scanf("%lld",&b);
    scanf("%lld",&c);
    diff = b-c;
    if(a < diff)
        printf("%lld",n/a);
    else{
        if(n>=b){
            cnt = (n-b)/diff+1;
            n-=diff*cnt;
        }
        cnt+=n/a;
        printf("%lld",cnt);
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int cmpfunc (const void * a, const void * b)
{
   return -( *(int*)a - *(int*)b );
}
int main()
{
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	qsort(a,n,sizeof(int),cmpfunc);
	//count=a[0];
	long long int sum=0;
	for(int i=0;i<n;i++)
	{
		//2int count=0;
		for(int j=i+1;j<n;j++)
		{
			if(a[i]==a[j]&&a[j]>0)
				a[j]=a[j]-1;

		}
		sum=sum+a[i];
	}
	printf("%lld\n",sum );
}


#include<stdio.h>
#include<string.h>
main()
{
int x=0,y=0,n,i,j,len,count=0;
char str[200];
scanf("%d\n",&n);
for(i=0;i<n;i++)
scanf("%c\n",&str[i]);

str[i]='\0';
len=strlen(str);

for(i=0;i<len;i++)
{
x=0;y=0;
for(j=i;j<len;j++)
{

if(str[j]=='R')
x=x+1;

if(str[j]=='L')
x=x-1;

if(str[j]=='U')
y=y+1;;

if(str[j]=='D')
y=y-1;

if(x==0&&y==0)
count++;

}

}
printf("%d",count);
}


#include <stdio.h>
int N,a,b,K;
//      k     n
int dp[2][5005];
long long int p[5005];
#define max(a,b) ((a) > (b)?(a):(b))
#define min(a,b) ((a) < (b)?(a):(b))
#define mod(a) ((a) % 1000000007)
int main(void)
{
	int count,k,sum,m,n;
	scanf("%d%d%d%d",&N,&a,&b,&K);

	for(count = 0;count <= N;count++)
		dp[0][count] = 1;
	dp[0][b] = 0;
	for(k = 1;k <= K;k++){
		dp[k % 2][b  - 1] = 0;
		dp[k % 2][b  + 1] = 0;
		for(p[0] = 0,count = 1;count <= N;count++)
			p[count] = p[count - 1] + dp[(k - 1)%2][count];
		if(a < b){
			for(count = 1;count < b - 1;count++)
				dp[k % 2][count] = mod(mod(p[b - 1] - p[count]) + mod(p[count - 1] - p[max(count - (b - count),0)]));
		}else{
			for(count = b + 2;count <= N;count++)
				dp[k % 2][count] = mod(mod(p[count - 1] - p[b]) + mod(p[min(count - b - 1 + count,N)] - p[count]));
		}
	}
	printf("%d",dp[K % 2][a]);
	return 0;
}


#include <stdio.h>

#define N	200000
#define MD	998244353

long long power(int a, int k) {
	long long p;

	if (k == 0)
		return 1;
	p = power(a, k >> 1);
	p = p * p % MD;
	if (k & 1)
		p = p * a % MD;
	return p;
}

int ff[N + 1], gg[N + 1];

void init() {
	int i, f;

	f = 1;
	for (i = 0; i <= N; i++) {
		gg[i] = power(ff[i] = f, MD - 2);
		f = (long long) f * (i + 1) % MD;
	}
}

int ch(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

int main() {
	int n, c, ans;
	long long k;

	init();
	scanf("%d%lld", &n, &k);
	ans = 0;
	if (k == 0)
		ans = ff[n];
	else if (k < n) {
		int x;

		x = 0;
		for (c = n - k; c >= 0; c--)
			x = (x + ((n - k - c) % 2 == 0 ? 1 : -1) * (ch(n - k, c) * power(c, n))) % MD;
		ans = (long long) ch(n, n - k) * x * 2 % MD;
		if (ans < 0)
			ans += MD;
	}
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
long long int abs(long long int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
int main()
{
	long long int x0, y0, ax, ay, bx, by;
	scanf("%lld %lld %lld %lld %lld %lld", &x0, &y0, &ax, &ay, &bx, &by);
	long long int xs, ys, t;
	scanf("%lld %lld %lld", &xs, &ys, &t);
	long long int x[102], y[102];
	x[0] = x0;
	y[0] = y0;
	long long int i, j;
	long long int max = 10000000000000016;
	for (i = 0; x[i] < max && y[i] < max; i++)
	{
		x[i + 1] = ax * x[i] + bx;
		y[i + 1] = ay * y[i] + by;
	}
	long long int c = i + 1;
	long long int ans = 0;
	for (i = 0; i < c; i++)
		for (j = 0; j < c; j++)
			if (abs(xs - x[i]) + abs(ys - y[i]) + abs(x[i] - x[j]) + abs(y[i] - y[j]) <= t)
				if (ans < abs(i - j) + 1)
					ans = abs(i - j) + 1;
	printf("%lld\n", ans);
	return 0;
}


/* practice with Dukkha */
#include <stdio.h>

int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }

int main() {
	int hp, atk, def, hp_, atk_, def_, h, a, d, ans, na, nd, nh;

	scanf("%d%d%d%d%d%d%d%d%d", &hp, &atk, &def, &hp_, &atk_, &def_, &h, &a, &d);
	ans = 0x3f3f3f3f;
	for (na = max(0, def_ + 1 - atk); na <= max(0, def_ + hp_ - atk); na++)
		for (nd = 0; nd <= max(0, atk_ - def); nd++) {
			int atk1 = atk + na - def_;
			int t = (hp_ + atk1 - 1) / atk1;

			nh = max(0, t * max(0, atk_ - def - nd) + 1 - hp);
			ans = min(ans, na * a + nd * d + nh * h);
		}
	printf("%d\n", ans);
	return 0;
}


/* https://codeforces.com/contest/1206/submission/59041923 (Dukkha) */
#include <stdio.h>
#include <stdlib.h>

#define N	1000

int next[1 + (N - 1) * 2], jj[1 + (N - 1) * 2];

int link(int l, int j) {
	static int l_ = 1;

	next[l_] = l;
	jj[l_] = j;
	return l_++;
}

int n;
int ao[N], cc[N];
int i_, j_, n_;

int dfs(int p, int i) {
	int l, j, c_, c;

	c = 1;
	for (l = ao[i]; l; l = next[l]) {
		j = jj[l];
		if (j != p)
			c += dfs(i, j);
	}
	c_ = c < n - c ? c : n - c;
	if (n_ < c_) {
		n_ = c_;
		if (c <= n - c) {
			i_ = i;
			j_ = p;
		} else {
			i_ = p;
			j_ = i;
		}
	}
	cc[i] = c;
	return c;
}

int compare(const void *a, const void *b) {
	int i = *(int *) a;
	int j = *(int *) b;

	return cc[i] - cc[j];
}

int a, b;

void dfs_(int p, int i, int c) {
	int l, j;

	a += b;
	printf("%d %d %d\n", p + 1, i + 1, a - c);
	c = a;
	for (l = ao[i]; l; l = next[l]) {
		j = jj[l];
		if (j != p)
			dfs_(i, j, c);
	}
}

int main() {
	static int tt[N];
	int h, i, j, k, l, s, n_, changed;

	scanf("%d", &n);
	for (h = 0; h < n - 1; h++) {
		scanf("%d%d", &i, &j), i--, j--;
		ao[i] = link(ao[i], j);
		ao[j] = link(ao[j], i);
	}
	i_ = -1, j_ = -1, n_ = -1;
	dfs(-1, 0);
	s = j_;
	dfs(-1, s);
	k = 0;
	for (l = ao[s]; l; l = next[l])
		tt[k++] = jj[l];
	qsort(tt, k, sizeof *tt, compare);
	n_ = 1;
	b = 1, a = 0;
	changed = 0;
	for (h = 0; h < k; h++) {
		j = tt[h];
		dfs_(s, j, 0);
		n_ += cc[j];
		if (!changed && n_ * 3 >= n) {
			changed = 1;
			b = n_, a = 0;
		}
	}
	return 0;
}


#include<stdio.h>
#define min(a,b) ((a<b)?a:b)
long long cal(long long a,long long b,long long c,long long la,long long l)
{
 long long x,val=a-b-c+la;
  if(val<=-1)
    return 0;
   x=min(val,l-la);
  return (x+1)*(x+2)/2;
}
int main()
{
 long long int i,a,b,c,l;
  scanf("%lld %lld %lld %lld",&a,&b,&c,&l);
   unsigned long long ans=(l+3)*(l+2)*(l+1)/6;
   for(i=0;i<=l;i++)
   ans-=cal(a,b,c,i,l);
   for(i=0;i<=l;i++)
   ans-=cal(b,a,c,i,l);
  for(i=0;i<=l;i++)
   ans-=cal(c,a,b,i,l);
  printf("%llu\n",ans);
 return 0;
}


#include <stdio.h>
int main() {
	int n;
	scanf("%d", &n);
	unsigned long long ans = 6;
	unsigned long long pow = 16;

	for(int i = 1; i < n; i++) {
		ans *= pow;
		ans %= 1000000007;
		pow *= pow;
		pow %= 1000000007;
	}

	printf("%llu\n", ans);

}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n=0,i=0,j=0,book[81]={0},max=0,now[81]={0},time[81]={0},money=0,number=0,de=0,k=0,chose=0;
    scanf("%d %d",&n,&max);
    for(i=0;i<n;i++)
        scanf("%d",&book[i]);
    for(i=0;i<n;i++)
    {
        if(now[book[i]]==0 && number<max)
        {
            now[book[i]]=1;
            money++;
            number++;
        }
        else if(now[book[i]]==0 && number==max)
        {
            for(j=0;j<81;j++)
                time[j]=0;
            for(j=i;j<n;j++)
            {
                if(now[book[j]]==1 && time[book[j]]==0)
                {
                    time[book[j]]=1;
                    de=book[j];
                }
            }
            for(j=0;j<81;j++)
            {
                chose=0;
                if(now[j]==1)
                {
                    //but=now[j];
                    for(k=i;k<n;k++)
                    {
                        if(j==book[k])
                            chose=1;
                    }
                    if(chose==0)
                        de=j;
                }

            }
            now[de]=0;
            now[book[i]]=1;
            money++;
        }
    }
    printf("%d\n",money);
    return 0;
}


#include<stdio.h>
int main()
{
    int m,num,count,i,mun;
    scanf("%d",&m);
    count=0;num=0;
    while(count<m)
    {
        num=num+5;
        count++;
        //printf("count=%d and num=%d\n",count,num);
        if(num%25==0 && num)
        {
            mun=num;
            while(mun%5==0)
            {
                mun/=5;
                count++;
            }
            count--;
        }
       // printf("count=%d and num=%d\n",count,num);

    }
    if(count==m)
    {
        printf("5\n");
        for(i=1 ; i<=5 ; i++ )
            printf("%d ",num++);

    }
    else
        printf("0");
    return 0;
}


#include<stdio.h>
int main()
{
    long long int n,k;
    scanf("%lld%lld",&n,&k);
    if(n==k||k==0){
        printf("0 0\n");
    }
    else if(k<=n/3){
        printf("1 %lld\n",2*k);
    }
    else if(k>n/3){
        printf("1 %lld\n",n-k);
    }
    return 0;
}


typedef long long int llint;
#include<stdio.h>
int main()
{
    llint r1;
    double y;
    scanf("%lld",&r1);
    double r=r1;

    for (llint i=1;i>0;i++)
    {
        y=(r-i-1-i*i)/(2*i);
        llint y1=y;
        if (y1==y&&y>0)
        {
          printf("%lld %lld",i,y1);
          return(0);
        }
        if (y<1)
        {
          printf("NO");
          return(0);
        }

    }
    return(0);
}


#include <stdio.h>
#include <math.h>

int main()
{
    long long int n,x,y;
    char ch;
    scanf("%lld%c",&n,&ch);
    x=n;
    if(n%2!=0)
        x=x+1;
    x=x/2;
    if(x%2!=0)
        x++;
    x=x/2;
    y=16*(x-1);
    if(n%2==0)
        y=y+7;
    if(ch=='f')
        y=y+1;
    else if(ch=='e')
        y=y+2;
    else if(ch=='d')
        y=y+3;
    else if(ch=='a')
        y=y+4;
    else if(ch=='b')
        y=y+5;
    else if(ch=='c')
        y=y+6;
    printf("%lld",y);
    return 0;
}


/* practice with Dukkha */
#include <stdio.h>

#define MD	1000000009

long long power(long long a, int k) {
	long long p;

	if (k == 0)
		return 1;
	p = power(a, k / 2);
	p = p * p % MD;
	if (k % 2)
		p = p * a % MD;
	return p;
}

int main() {
	int n, m, k, z, d;

	scanf("%d%d%d", &n, &m, &k);
	z = n - m;
	if (z >= (n + k - 1) / k) {
		printf("%d\n", m);
		return 0;
	}
	d = (n - z * k) / k;
	printf("%lld\n", ((power(2, d + 1) - 2 + MD) * k + (m - d * k)) % MD);
	return 0;
}


#include <stdio.h>
#define mod 1000000007
int dp[2001][2001];
int main()
{
	 int n,k,i,j,l;
	 scanf("%d%d",&n,&k);

	 memset(dp,0,sizeof(dp));

	 for (i=1;i<=2000;i++)
	 dp[1][i]=1;             // dp[i][j] : length i and last number j

	 for (i=1;i<k;i++)
	 {
	 	 for (j=1;j<=n;j++)
	 	 {
	 	 	 for (l=1;l*j<=n;l++)
	 	 	 dp[i+1][l*j]=(dp[i+1][l*j]%mod+dp[i][j]%mod)%mod;
	 	 }
	 }

	     int sum=0;
	 	 for (j=1;j<=n;j++)
	 	 sum=(sum%mod+dp[k][j]%mod)%mod;

	 printf("%d\n",sum);
	 return 0;
}


#include <stdio.h>
#define MOD 1000000007

int K;
long long PA,PB,ans;

long long INV1,INV2;
long long f[1010][2010];

long long power(long long a,int b)
{
    long long y = 1;
    for(;b;b>>=1)
    {
        if(b&1) y = y * a % MOD;
        a = a * a % MOD;
    }
    return y;
}

int main()
{
    int i,j;
    long long x,y;

    scanf("%d%I64d%I64d",&K,&PA,&PB);
    INV1 = power(PA+PB,MOD-2);
    INV2 = power(PB,MOD-2);

    f[1][0] = 1;
    for(i=1;i<=K;i++) for(j=(i==1);j<=2*K;j++)
    {
        if(j < K) f[i][j] = f[i-1][j] * PA % MOD * INV1 % MOD;
        if(j >= i && j-i < K) f[i][j] = (f[i][j] + f[i][j-i] * PB % MOD * INV1) % MOD;
    }

    for(i=1;i<K;i++) for(j=K;j<=2*K;j++) ans = (ans + j*f[i][j]) % MOD;
    for(i=0;i<K;i++) ans = (ans + (PA*INV2 + K+i) % MOD * f[K][i]) % MOD;

    printf("%I64d\n",ans);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,feet,tmp,inch;
    scanf("%d",&n);
    inch=n/3;
    if(n%3==2)
    {
        inch++;
    }
    feet=inch/12;
    inch=inch%12;
    printf("%d %d\n",feet,inch);
    return 0;
}


#include<stdio.h>
int main(void)
{
	int n;
	scanf("%d",&n);
	if(n&1)
	{
		printf("0\n");
	}
	else
	{
		printf("%d\n",1<<n/2);
	}
}


#include <stdio.h>

long long extgcd(long long a, long long b, long long *x, long long *y)
{
     long long d = a;

     if (b != 0) {
	  d = extgcd(b, a % b, y, x);

	  *y -= (a / b) * (*x);
     } else {
	  *x = 1;
	  *y = 0;
     }

     return d;
}

long long mod_inverse(long long a, long long m)
{
     long long x, y;

     extgcd(a, m, &x, &y);

     return (m + x % m) % m;
}

int main()
{
     int n, m = 1000000007, i;
     long long a1 = 1, a2 = 1, a3 = 1, c;

     scanf("%d", &n);

     for (i = 1; i <= 2 * n - 1; i++) {
	  a1 *= i;
	  a1 %= m;
     }

     for (i = 1; i <= n; i++) {
	  a2 *= i;
	  a2 %= m;
     }

     for (i = 1; i <= n - 1; i++) {
	  a3 *= i;
	  a3 %= m;
     }

     c = a1 * mod_inverse(a2 * a3 % m, m) % m;
     c *= 2;
     c -= n;
     c %= m;

     printf("%I64d\n", c);

     return 0;
}


#include<stdio.h>
#define N 1000000007
int main()
{
    long long int a,b;
    register long long int i,j,ans;
    scanf("%lld%lld",&a,&b);
    long long int arr[4];
    int count=0;
    arr[0]=a;
    arr[1]=b;
    arr[2]=b-1;
    arr[3]=a*b+b+2;
    while(count!=2)
    {
    for(i=0;i<4;i++)
    {
        if(arr[i]%2==0)
        {
            arr[i]=arr[i]/2;
            count++;
        }
        if(count==2)
            break;
    }
    }
    arr[3]=arr[3]%N;
    ans=(((((arr[0]*arr[1])%N)*arr[2])%N)*arr[3])%N;
    printf("%lld",ans);
    return 0;
}


/*  AUTHOR:AKASH JAIN
*   USERNAME:akash19jain
*   DATE:21/07/2019
*/
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define MOD 1000000007
int cmp(const void * a,const void * b);

int main()
{
    long long t=1,i=0;
    //scanf("%lld",&t);
    while(t--)
    {
        long long n,k;
        scanf("%lld%lld",&n,&k);
        long long l=-1,r=n+1;
        while(r-l>1)
        {
            long long m=(l+r)/2;
            if((n-m)*(n-m+1)/2-m>k)
                l=m;
            else
                r=m;
        }
        printf("%lld\n",r);
    }
}

//qsort(arr,n,sizeof(arr[0]),cmp);
int cmp(const void * a,const void * b)
{
    return (*(int*)a - *(int*)b);
}


#include <stdio.h>

int main() {
	int n;
	int i;
	int a, b = 0, c = 0;
	int sum = 0;
	scanf("%d", &n);
	scanf("%d", &c);
	for(i=1; i<n; i++) {
		a = b;
		b = c;
		scanf("%d", &c);
		if(b + c == 5) {
			printf("Infinite");
			return 0;
		}
		sum += b + c;
		if(a == 3 && b == 1 && c == 2) sum--;
	}
	printf("Finite\n");
	printf("%d", sum);
	return 0;
}


#include <stdio.h>
int main()
{
int x,y,clr,i;
long int val;
scanf("%d %d",&x,&y);
val = x*x + y*y;
for(i=0;i<=1415;i++)
{
    if (val == i*i)
    {
        clr=1;
        goto X;
    }
    if (val < i*i)
    {
        if((x*y) >0)
        {
            clr = i%2;
            goto X;
        }
        else
        {
            clr = 1 - i%2;
            goto X;
        }
    }
}
X:
if (clr == 1) printf("black");
else printf ("white");
return(0);
}


#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define eps 1e-4
#define PI acos(-1.0)
char s[10][15];
int sti[4]={0,1,4,7},eni[4]={0,3,6,9};
int stj[4]={0,0,4,8},enj[4]={0,2,6,10};
void printall2()
{
	for (int i=1;i<=9;i++)
	{
		for (int j=0;j<=10;j++)
			if (s[i][j]=='.') printf("!");
			else printf("%c",s[i][j]);
		printf("\n");
		if (!(i%3)) printf("\n");
	}
}
void printall1()
{
	for (int i=1;i<=9;i++)
	{
		for (int j=0;j<=10;j++)
			printf("%c",s[i][j]);
		printf("\n");
		if (!(i%3)&&i!=9) printf("\n");
	}
}
int main()
{
	for (int i=1;i<=3;i++) gets(s[i]);
	gets(s[0]);
	for (int i=4;i<=6;i++) gets(s[i]);
	gets(s[0]);
	for (int i=7;i<=9;i++) gets(s[i]);
	int n,m;
	scanf("%d%d",&n,&m);
	n%=3; m%=3;
	if (!n) n=3;
	if (!m) m=3;
	int flag=0;
	for (int i=sti[n];i<=eni[n];i++)
		for (int j=stj[m];j<=enj[m];j++)
			if (s[i][j]=='.')
			{
				flag++;
				s[i][j]='!';
			}
	if (flag) printall1();
	else printall2();
	return 0;
}


#include <stdio.h>

int main() {
	long long d, ans, k, a, b, t;

	scanf("%lld%lld%lld%lld%lld", &d, &k, &a, &b, &t);
	if (d < k)
		ans = d * a;
	else {
		ans = k * a + (d - k) * b;
		if (ans > (d / k) * (k * a + t) - t + (d % k) * b)
			ans = (d / k) * (k * a + t) - t + (d % k) * b;
		if (ans > (d / k) * (k * a + t) + (d % k) * a)
			ans = (d / k) * (k * a + t) + (d % k) * a;
	}
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>
int dp [50000];
int tam;
void CalculaT(){
	int i = 1;
	dp [0] = 1;
	while (dp[i - 1] < 1000000000){
		dp[i] = dp[i - 1] + (i+1);
		i++;
	}
	tam = i - 1;
}

int BusquedaBin(int ini, int fin, int x){
	if (ini > fin) return -1;
	int mitad = (ini + fin) / 2;
	if (dp[mitad] == x)
		return mitad;
	if (dp[mitad] < x)
		return BusquedaBin(mitad + 1, fin, x);
return BusquedaBin(ini, mitad - 1, x);
}

int main (void){
	int n, i, cont = 0;
	scanf ("%d", &n);
	CalculaT();
	for (i = 0; i < tam; i++){
		if (BusquedaBin(0, tam, n - dp[i]) >= 0 && cont == 0){
			printf ("YES\n");
			cont++;
		}
	}
	if(cont == 0)
		printf("NO\n");
return 0;
}


#include "stdio.h"
#include "math.h"

#define MAX 110

int main()
{
	int n, pos, l, r;
	while (scanf("%d%d%d%d", &n, &pos, &l, &r) != EOF) {
		int left, right, ans = 0;
		left = l - 1;
		right = n - r;
		if (left != 0 && right != 0) {
			if (abs(pos - l) <= abs(pos - r)) {
				ans += abs(pos - l);
				ans += 1;
				ans += r - l;
				ans += 1;
			}
			else {
				ans += abs(pos - r);
				ans += 1;
				ans += r - l;
				ans += 1;
			}
		}
		else if (left == 0 && right != 0) {
			ans += abs(pos - r);
			ans += 1;
		}
		else if (left != 0 && right == 0) {
			ans += abs(pos - l);
			ans += 1;
		}
		printf("%d\n", ans);
	}
	return 0;
}


#include<stdio.h>
int prime(unsigned long long int x){
    unsigned long long  int i=2,flag=0;
    for(i=2;i*i<=x;i++){
        if(x%i==0){
            flag=1;
            break;
        }
    }
    if(flag==0)
        return 1;
    else if(flag==1)
        return 0;

}
int main(){
    unsigned long long int a,b,c;
    int t;
    scanf("%d",&t);
    for(int i=0;i<t;i++){
        scanf("%llu %llu",&a,&b);
        if(a==b+1){
            prime(a+b)? printf("YES\n"):printf("NO\n");
        }
        else printf("NO\n");
        /*c=a*a-b*b;
        (c==a+b)? printf("YES\n"):printf("NO\n");*/
    }
}


#include <stdio.h>

long long gcd(long long a, long long b) {
	return b == 0 ? a : gcd(b, a % b);
}

int main() {
	long long n, m, k;

	scanf("%lld%lld", &n, &k);
	m = 1;
	while (k-- > 0)
		m *= 10;
	printf("%lld\n", n * m / gcd(n, m));
	return 0;
}


#include <stdio.h>

int countzeroes(int x, int s[])
{
	int count=0;
	for(int j=0;j<=x;j++){
		if(s[j]==0)
			count++;
	}
	return count;
}

int countones(int x, int s[])
{
	int count=0;
	for(int j=0;j<=x;j++){
		if(s[j]==1)
			count++;
	}
	return count;
}

int main(void) {
	int n,i;  //n is the total number of games.
	scanf("%d",&n);

	int s[n];
	for(i=0;i<n;i++)
		scanf("%d",&s[i]);

	/*for(i=0;i<n;i++)
		printf("%d",s[i]); */

	int zeroes,ones;
	zeroes=countzeroes(n-1,s);
	ones=countones(n-1,s);

	int zero[zeroes],x,y,counter=0;
	for(i=0;i<n;i++){
		if(s[i]==0){
			x=countzeroes(i,s);
			y=ones-countones(i,s);
			//printf("%d %d   %d\n",x,y,x+y);
			zero[counter]=x+y;
			counter++;
		}
	}

	/*for(i=0;i<zeroes;i++)
		printf("%d",zero[i]);
	printf("\n");*/

	int ans;
	if(zeroes>ones)
		ans=zeroes;
	else
		ans=ones;

	//printf("ans is %d \n", ans);

	for(i=0;i<zeroes;i++){
		if(zero[i]>ans)
			ans=zero[i];
	}

	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>

double myfunc(double giv,int g,int r)
{
	int sum=0,f=0;
	while(sum<=giv)
	{
		if(f==0)
			sum=sum+g;
		else
			sum=sum+r;
		f=1-f;
	}
	if(f==0)
		return sum-giv;
	else
		return 0;
}

int main()
{
	int l,d,v,g,r,d1;
	double t1,t2,t3;
	scanf("%d%d%d%d%d",&l,&d,&v,&g,&r);
	d1=(l-d);
	t1=(double)d/v;

	t2=myfunc(t1,g,r);

	t3=(double)d1/v;
	printf("%0.8f",t1+t2+t3);
	return 0;
}


#include<stdio.h>

int main()
{
    int a,i,j,k,flag,count=0;
    scanf("%d",&a);
    char arr[a][a],oth[a][a],change[a][a],matha_nosto[a][a];
    for(i=0; i<a; i++)
    {
        for(j=0; j<a; j++)
            scanf(" %c",&arr[i][j]);
    }

    for(i=0; i<a; i++)
    {
        for(j=0; j<a; j++)
            scanf(" %c",&oth[i][j]);
    }

    for(i=0; i<a; i++)
    {
        for(j=0; j<a; j++)
            change[j][a-1-i]=oth[i][j];
    }
    for(k=0; k<a+6; k++)
    {
        for(i=0; i<a; i++)
        {
            for(j=0; j<a; j++)
            {
                if(arr[i][j]==change[i][j])
                    flag=1;
                else
                {
                    flag=0;
                    break;
                }
            }
            if(flag==0)
                break;
        }
        if(flag==1)
        {
            printf("YES");
            return 0;
        }
        else
        {
            for(i=0; i<a; i++)
            {
                for(j=0; j<a; j++)
                {
                    if(arr[i][j]==change[i][a-1-j])
                        flag=1;
                    else
                    {
                        flag=0;
                        break;
                    }
                }
                if(flag==0)
                    break;
            }
            if(flag==1)
            {
                printf("YES");
                return 0;
            }
            else
            {
                for(i=0; i<a; i++)
                {
                    for(j=0; j<a; j++)
                        oth[i][j]=change[i][j];
                }

                for(i=0; i<a; i++)
                {
                    for(j=0; j<a; j++)
                        change[j][a-1-i]=oth[i][j];
                }
            }
        }

    }
    printf("NO");
    return 0;
}


#include<stdio.h>
int main()
{

   long int n,i,c=0;
    scanf("%ld",&n);

        c = n*n + (n-1)*(n-1);

    printf("%ld\n",c);

    return 0;

}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a, b, c, d, e, f;
    int res=0;
    scanf("%d %d %d %d %d %d", &a,&b,&c,&d,&e,&f);
    res=(a+b+c)*(a+b+c)-a*a-c*c-e*e;
    printf("%d", res);
    return 0;
}


#include <stdio.h>
int main()
{
    long long sum=0,n,k;
    scanf("%lld%lld",&n,&k);
    if(n==1)
    {
        printf("0\n");
        return 0;
    }
    else if(k>=n/2)
    {

        sum=(n-1)*n/2;
        printf("%lld\n",sum);
    }
    else
    {
        int i;
        long long j=n;
        for(i=0;i<k;i++)
        {
            sum=sum+j-1;
            j--;
        }
        for(i=1;i<k;i++)
        {
            sum=sum+i;
        }
        sum=sum+(n-2*k)*k;
        printf("%lld\n",sum);
    }
}


#include<stdio.h>

int main()
{
	long long int i,j,k;
	long long int a,b;
	scanf("%lld %lld",&a,&b);

	i=0;
	while(a>0 && b>0)
	{
		if(a>b)
		{
			k = a/b;
			i += k;
			a = a - k*b;
		}
		else
		{
			k = b/a;
			i +=k;
			b = b - k*a;
		}
	}

	printf("%lld\n",i);
	return 0;
}


#include<stdio.h>
int main()
{
    int a,b,c,p,q,m,n;
    scanf("%d %d %d",&a,&b,&c);
    if(a+b>c&&b+c>a&&c+a>b)
    {
        p=0;
    }
    else{
        if(a+b<=c){
            m=a+b;
            p=c-m+1;
        }
        else if(b+c<=a){
            m=b+c;
            p=a-m+1;
        }
        else if(c+a<=b){
            m=c+a;
            p=b-m+1;
        }

    }
    printf("%d\n",p);
    return 0;

}


#include <stdio.h>
#include <stdint.h>
#include <assert.h>

#define MOD 1000000007LL

// we will consider numbers with <= 10^6 digits. Hence, maximal sum of digits is 9*10^6 < 10^7.
// we can generate all possible sums for excellent numbers:
//   2^n for n digits of a,b and then we need to sum for n = 1..7, meaning that 2^8 - 2 different possible sums:
//   1+2+..+2^[n-1] = 2^n - 1, hence 2+..+2^[n-1] = 2^n - 2
// now for every possible sum we need to solve:
// ax + by = S
// x + y = N
// and this will add binomial(N,x) numbers
// trivially, writing x = N - y, (b - a)y = S - aN

static inline int min(int a, int b) { return a < b ? a : b; }

static int _sd[254] = {};
static void generate_sd(int a, int b) {
    int sd_count = 0;
    for(int i = 1 ; i <= 7 ; ++i) {                // fix number of digits
        for(int j = 0, jn = 1<<i ; j < jn ; ++j) { // enumerate masks
            int n = 0, m = j;
            for(int k = 0, p10 = 1 ; k < i ; ++k, p10 *= 10, m >>= 1)
                n += p10 * (m & 0x1 ? b : a);
            assert(sd_count < 254); _sd[sd_count++] = n;
        }
    }
}

// precalculate factorials mod MOD.
// we can calculate binomial(n,k) mod M = [n! mod M] * [k!(n-k)!]^-1 mod M
// as MOD is prime number x^-1 mod MOD = x^(MOD-2)
static int64_t _fact[1000001];

static inline uint64_t pow_mod(int64_t a, int64_t pow, int64_t mod) {
    if(pow == 0) return 1;
    while(pow % 2 == 0) { a = (a*a) % mod; pow /= 2; }
    int64_t ret = a; pow /= 2;
    while(pow) {
        a = (a*a) % mod;
        if(pow % 2 != 0) ret = (ret*a) % mod;
        pow /= 2;
    }
    return ret;
}

static inline int64_t binomial_mod(int n, int k) {
    const int64_t nf = _fact[n], kf = _fact[k], nkf = _fact[n-k], denom = (kf*nkf) % MOD;
    return (nf * pow_mod(denom, MOD-2, MOD)) % MOD;
}

int main() {
    int A,B,N; scanf("%d %d %d\n", &A,&B,&N);
    generate_sd(A,B);
    _fact[0] = 1; for(int i = 1 ; i <= N ; ++i) _fact[i] = (i*_fact[i-1]) % MOD;

    int64_t count = 0;
    for(int si = 0 ; si < 254 ; ++si) {
        const int ss = _sd[si] - A*N;
        if(ss % (B-A) == 0) {
            const int y = ss / (B-A), x = N - y;
            if(x >= 0 && y >= 0) {
                count = (count + binomial_mod(N,y)) % MOD;
            }
        }
    }
    printf("%d\n", (int)count);
}


#include <stdio.h>
#include <stdlib.h>
int a[35], n, m, arr1[1<<20], arr2[1<<20];
int idx1, idx2;
int mycmp(const void* a, const void* b) { return *(int *)a - *(int *)b;}
void dfs(int i, int sum, int type){
  if (type && i==n) {arr2[idx2++] = sum; return;}
  else if (!type && i==n/2) {arr1[idx1++]= sum; return ; }
  dfs(i+1, (sum+a[i])%m , type);
  dfs(i+1, sum, type);
}
int lbound(int v){
  int s=0, e=idx2;
  while (e>s){
    int mid=(s+e)/2;
    if (arr2[mid] >= v) e=mid;
    else s=mid+1;
  }
  return e;
}
int main(){
  scanf("%d %d", &n, &m);
  for (int i=0; i<n; i++){
    scanf("%d", &a[i]);
    a[i]%=m;
  }
  qsort (a, n, sizeof(int), mycmp);

  dfs(0, 0, 0);
  dfs(n/2, 0, 1);
  arr1[idx1++]=0;
  arr2[idx2++]=0;

  for (int i=0; i<idx1; i++) arr1[i]%=m;
  for (int i=0; i<idx2; i++) arr2[i]%=m;

  qsort(arr1, idx1, sizeof(int), mycmp);
  qsort(arr2, idx2, sizeof(int), mycmp);

  int ans=0;
  for (int i=0; i<idx1; i++){
    int j=lbound(m-arr1[i]);
    j--;
    int tmp=(arr1[i]+arr2[j])%m;
    if ( j>=0) ans=tmp>ans?tmp:ans;
  }
  printf("%d\n", ans);
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#ifdef __linux__
#define LLD     "%lld"
#else
#define LLD     "%I64d"
#endif

char rct[16][16];
int dpr[16][16];

int
main()
{
	int	r, c, n, K;
	int	i, j, k, m;
	int	ways = 0;

	scanf ("%d%d%d%d", &r, &c, &n, &K);

	for (i = 0; i < n; i++) {
		int x, y;

		scanf ("%d%d", &x, &y);
		rct[x][y] = 1;
	}

	for (i = 1; i <= r; i++) {
		for (j = 1; j <= c; ++j) {
			dpr[i][j] = dpr[i][j-1];

			if (rct[i][j]) {
				dpr[i][j] = dpr[i][j-1]+1;
			}
		}
	}

	for (m = 0; m < r; m++) {
		for (i = m+1; i <= r; ++i) {
			int l;

			for (l = 0; l < c; ++l) {
				for (j = l+1; j <= c; ++j) {
					int  vs = 0;
					for (k = m+1; k <= i; ++k) {
						vs += (dpr[k][j] - dpr[k][l]);
					}
					if (vs >= K) {
						ways += c-j+1;
						break;
					}
				}
			}
		}
	}
	printf("%d\n", ways);
	return 0;
}


#include<stdio.h>
int main(){
	long long a,b;
	scanf("%lld%lld", &a,&b);
	if(b%a!=0)
	printf("%d",(b/a)+1);
	else
	printf("%d", b/a);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define MAX 1000010
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

long long len, n, m, k, x, y;
long long X[MAX], Y[MAX], counter[1010][1010];

int main(){
    long long i, j, v, min_v, max_v;

    while (scanf("%lld %lld %lld %lld %lld", &n, &m, &k, &x, &y) != EOF){
        len = 0;
        clr(counter);
        for (i = 1; i < n; i++){
            for (j = 1; j <= m; j++){
                X[len] = i, Y[len++] = j;
            }
        }
        for (i = n; i > 1; i--){
            for (j = 1; j <= m; j++){
                X[len] = i, Y[len++] = j;
            }
        }

        if (n == 1){
            for (i = 1; i <= m; i++) X[len] = 1, Y[len++] = i;
        }

        for (i = 0; i < len; i++) counter[X[i]][Y[i]] += (k / len);
        k %= len;
        for (i = 0; i < k; i++) counter[X[i]][Y[i]]++;

        min_v = max_v = counter[1][1];
        for (i = 1; i <= n; i++){
            for (j = 1; j <= m; j++){
                if (counter[i][j] < min_v) min_v = counter[i][j];
                if (counter[i][j] > max_v) max_v = counter[i][j];
            }
        }

        printf("%lld %lld %lld\n", max_v, min_v, counter[x][y]);
    }
    return 0;
}


#include<stdio.h>

int main(void)
{
	int n, k;
	int a[101];
	int i, j;
	int sum = 0;
	int aa, b, c, d, e ,f;

	scanf("%d %d", &n, &k);
	aa = n * 8; b = n * 2; d = 0; e = 0; f = n;
	for (i = 1; i <= k; i++)
	{
		scanf("%d", &a[i]);
		if (a[i] % 2 != 0)
			{ e++; a[i]--; }
		else if (a[i] / 2 % 2 != 0)
		{
			if (b > 0) b--;
			else { a[i]+=2; d++; }
		}
		sum += a[i];
	}
	d = d>n?n:d;
	if (d < e)
		sum += 2 * (e - d);
	else if (d > e)
	    sum -= 2 * (d - e);

	if (sum <= aa)
		printf("YES");
	else
		printf("NO");

	return 0;

}


#include<stdio.h>
int main()
{
    long long int a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    if(a==b){
        printf("%lld",a+b+2*c);
    }
    else if(a>b){
        printf("%lld",2*b+1+2*c);
    }
    else{
        printf("%lld",2*a+1+2*c);
    }
}


#include <stdio.h>
#include <string.h>

int min(int a,int b){
    if(a<b) return a;
    return b;
}
int main(){
    char ice[201];
    int tnum[10]={0,},num[10]={0,},i,t,cnt=10000000;
    scanf("%d%s",&t,ice);
    for(i=0;i<strlen(ice);i++){
        num[(int)(ice[i]-48)]++;
    }
    while(t){
        tnum[t%10]++;
        t/=10;
    }
    num[2]+=num[5];
    num[6]+=num[9];
    tnum[2]+=tnum[5];
    tnum[6]+=tnum[9];
    for(i=0;i<10;i++){
        if(tnum[i] && i!=5 && i!=9) cnt=min(cnt,num[i]/tnum[i]);
    }
    printf("%d",cnt);
    return 0;
}


#include<stdio.h>
#define ll long long

ll gcd(ll a, ll b) {
  return b == 0 ? a : gcd(b, a % b);
}

int main()
{
    ll n, i, j, ans=0;
    scanf("%lld", &n);
    for(i=2; i*i<=n; i++)
    {
        if(n%i==0)
        {
            ans = gcd(ans, i);
            ans = gcd(ans, n/i);
        }
    }
    ans = gcd(ans, n);
    printf("%lld\n", ans);

    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int max(int a,int b)
{
    if(a>b)
        return a;
    else
        return b;
}
int main()
{
    int len1,len2,k,mx=0,i,j;
    char s[99999],t[99999];
    int p=0,q=0;
    scanf("%s",s);
    scanf("%s",t);
    len1=strlen(s);
    len2=strlen(t);
    int a[100000];
    int b[100000];
    for(int i = 0, j = 0; i < len1&& j < len2; ++i)
        if(s[i] == t[j])
            a[j++] = i;
    for(int i = len1 - 1, j = len2 - 1; i >= 0 && j >= 0; --i)
        if(s[i] == t[j])
            b[j--] = i;
    mx = max(mx,b[0]);
    mx = max(mx,len1 - a[len2-1] - 1);
    for(int i = 1; i < len2; i++)
        mx = max(mx,b[i] - a[i-1] - 1);
    printf("%d",mx);
    return 0;
}


//DURING CONTEST: http://www.codeforces.com/contest/699/submission/19246509

#include <stdio.h>
#include <stdint.h>
int main() {
    /**
     * Variables are stored as follows:
     * whatWeCouldDoYesterday -- data & 0b11
     * whatWeCanDoToday       -- (data & 0b1100) >> 2
     * answer                 -- (data & 0xff00) >> 8
     * numDays                -- (data & 0xff0000) >> 16
     * todayCode              -- (data & 0xff000000) >> 24
    */

    //whatWeDidYesterday = whatWeCanDoToday = answer = numDays = todayCode = 0;
    uint32_t data = 0;
    //scanf("%i", &numDays);
    scanf("%hhi", ((signed char*)&data)+2);
    //whatWeCouldDoYesterday = 3;
    data += 3;
    //while ((numDays -= 1), numDays+1) {
    while ((data -= 0x10000), ((data+0x10000) & 0xff0000) >> 16) {
        //scanf("%i", &todayCode);
        scanf("%hhi", ((signed char*)&data)+3);
        //if ((whatWeCouldDoYesterday & 2) && (todayCode & 1)) whatWeCanDoToday += 1;
        if ((data & 2) && (data & 0x1000000) >> 24) data += 1 << 2;
        //if ((whatWeCouldDoYesterday & 1) && (todayCode & 2)) whatWeCanDoToday += 2;
        if ((data & 1) && (data & 0x2000000) >> 24) data += 2 << 2;
        //if (!whatWeCanDoToday) answer += 1, whatWeCanDoToday = 3;
        if (!(data & 0b1100)) data += 1 << 8, data += 3 << 2;
        //whatWeCouldDoYesterday = whatWeCanDoToday, whatWeCanDoToday = 0;
        *((signed char*)&data) >>= 2;
    }
    //printf("%i\n", answer);
    printf("%li\n", (data & 0xff00) >> 8);
}


#include <stdio.h>
#include <string.h>
int main()
{int a,b,c=0,d,e,f,i,j,k,p=1,q,r,sum=1;
 char s[200];
 int z[102];
 scanf("%d",&d);
 scanf("%s",&s);

 for(i=0;i<d;i++)
 {if(s[i]=='*')
  {z[c]=i;
   c=c+1;}
   }
 for(j=0;j<c-1;j++)
    {   sum=0;

        for(k=j+1;(j+k)<c;k++)
              {e=z[j+k]-z[j];
              f=z[j+k];
              while(f<=d)
              {
               f=f+e;

              if(s[f]=='*')
              {
                  sum=sum+1;
              }
              else
              {
                  break;
              }

          }}
          if(sum>=4)
          {
              break;
          }
    }
    if(sum>=4)
    {
        printf("yes\n");
    }
    else
    {
        printf("no\n");
    }
return 0;}


#include<stdio.h>
#include<math.h>
int main(){
	int n;
	scanf("%d",&n);
	int t=0;
	for(int i=1;i<n;i++){
		int o=1;
		long long int ans=i;
		while(o!=n-1){
			if((ans-1)%n==0){
				break;
			}
			else{
				o++;
				ans=(ans*i)%n;
			}
		}
		if(o==n-1){
			if((ans)%n==1){
			t++;
			}
		}
	}
	printf("%d\n",t);
}


#include <stdio.h>
#include <stdlib.h>

#define N	200000
#define L_	19	/* L_ = ceil(log2(N * 2 + 1)) */
#define N_	(1 << L_)
#define MD	998244353

int min(int a, int b) { return a < b ? a : b; }

long long power(long long a, int k) {
	long long p = 1;

	while (k) {
		if (k & 1)
			p = p * a % MD;
		a = a * a % MD;
		k >>= 1;
	}
	return p;
}

int vv[N + 1], ff[N + 1], gg[N + 1], mobius[N + 1];
int *wwu[L_ + 1], *wwv[L_ + 1], vv_[L_ + 1];

void init() {
	int i, j, l, u, v;

	ff[0] = gg[0] = 1;
	for (i = 1; i <= N; i++) {
		vv[i] = i == 1 ? 1 : (long long) vv[i - MD % i] * (MD / i + 1) % MD;
		ff[i] = (long long) ff[i - 1] * i % MD;
		gg[i] = (long long) gg[i - 1] * vv[i] % MD;
	}
	for (i = 2; i <= N; i++) {
		if (mobius[i])
			continue;
		for (j = i; j <= N; j += i)
			mobius[j]++;
	}
	for (i = 2; i <= N / i; i++)
		for (j = i * i; j <= N; j += i * i)
			mobius[j] = -1;
	for (i = 1; i <= N; i++)
		mobius[i] = mobius[i] == -1 ? 0 : (mobius[i] % 2 == 0 ? 1 : -1);
	u = power(3, MD - 1 >> L_), v = power(u, MD - 2);
	for (l = L_; l > 0; l--) {
		int n = 1 << l, m = n >> 1;

		wwu[l] = (int *) malloc(m * sizeof *wwu[l]);
		wwv[l] = (int *) malloc(m * sizeof *wwv[l]);
		wwu[l][0] = wwv[l][0] = 1;
		for (i = 1; i < m; i++) {
			wwu[l][i] = (long long) wwu[l][i - 1] * u % MD;
			wwv[l][i] = (long long) wwv[l][i - 1] * v % MD;
		}
		vv_[l] = power(1 << l, MD - 2);
		u = (long long) u * u % MD, v = (long long) v * v % MD;
	}
	vv_[0] = 1;
}

int choose(int n, int k) {
	return (long long) ff[n] * gg[k] % MD * gg[n - k] % MD;
}

void ntt_(int *aa, int l, int inverse) {
	if (l) {
		int n = 1 << l, m = n >> 1, *ww = inverse ? wwv[l] : wwu[l], i, j;

		ntt_(aa, l - 1, inverse), ntt_(aa + m, l - 1, inverse);
		for (i = 0; (j = i + m) < n; i++) {
			int a = aa[i], b = (long long) aa[j] * ww[i] % MD;

			if ((aa[i] = a + b) >= MD)
				aa[i] -= MD;
			if ((aa[j] = a - b) < 0)
				aa[j] += MD;
		}
	}
}

void ntt(int *aa, int l, int inverse) {
	int n = 1 << l, i, j;

	for (i = 1, j = 0; i < n; i++) {
		int b = n >> 1, tmp;

		while ((j ^= b) < b)
			b >>= 1;
		if (i < j)
			tmp = aa[i], aa[i] = aa[j], aa[j] = tmp;
	}
	ntt_(aa, l, inverse);
}

int solve(int n, int k) {
	static int aa[N_], bb[N_];
	int n_, l_, i, ans;

	k = min(k, n);
	l_ = 0;
	while (1 << l_ < k + k + 1)
		l_++;
	n_ = 1 << l_;
	for (i = 0; i < n_; i++)
		aa[i] = i <= k ? (long long) power(i, n) * gg[i] % MD : 0;
	for (i = 0; i < n_; i++)
		bb[i] = i <= k ? (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD : 0;
	ntt(aa, l_, 0), ntt(bb, l_, 0);
	for (i = 0; i < n_; i++)
		aa[i] = (long long) aa[i] * bb[i] % MD;
	ntt(aa, l_, 1);
	ans = MD - 1;
	for (i = 0; i <= k; i++)
		ans = (ans + (long long) aa[i] * vv_[l_]) % MD;
	return ans;
}

int main() {
	int n, k, d, ans;

	init();
	scanf("%d%d", &n, &k);
	if (k == 1 || n == 1) {
		printf("1\n");
		return 0;
	}
	ans = 0;
	for (d = 1; d < n; d++)
		if (mobius[d])
			ans = (ans + solve((n + d - 1) / d, k) * mobius[d]) % MD;
	if (ans < 0)
		ans += MD;
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXN 23333
#define MAXELEM 308

int n, t;
int a[MAXN];

// Calculate the longest non-decreasing sequence
// Time complexity: O(n log n)
int *lnds(int *a, int n)
{
    int *ret = (int *)malloc(n * sizeof(int));
    int a_with_f[MAXN], maxlen = 1;
    ret[0] = 1;
    a_with_f[0] = -1;
    a_with_f[1] = a[0];
    int lo, hi, mid, i;
    for (i = 1; i < n; ++i) {
        if (a[i] >= a_with_f[maxlen]) {
            a_with_f[++maxlen] = a[i];
        } else {
            lo = 0, hi = maxlen;
            while (lo < hi - 1) {
                mid = (lo + hi) / 2;
                if (a[i] >= a_with_f[mid]) lo = mid;
                else hi = mid;
            }
            a_with_f[lo + 1] = a[i];
        }
        ret[i] = maxlen;
    }
    return ret;
}

int main()
{
    scanf("%d%d", &n, &t);
    int i;
    for (i = 0; i < n; ++i) scanf("%d", &a[i]);
    if (t <= 233) {
        for (i = n; i < n * t; i += n)
            memcpy(a + i, a, n * sizeof(int));
        int *first_part = lnds(a, n * t);
        printf("%d\n", first_part[n * t - 1]);
    } else {
        for (i = n; i < n * 233; i += n)
            memcpy(a + i, a, n * sizeof(int));
        int *first_part = lnds(a, n * 233);
        int count[MAXELEM] = { 0 }, maxcount = 0;
        for (i = 0; i < n; ++i) ++count[a[i]];
        for (i = 0; i < MAXELEM; ++i) if (maxcount < count[i]) maxcount = count[i];
        for (i = 0; i < n * 233; i += n)
            if (first_part[i + n] - first_part[i] == maxcount) break;
        i /= n;
        // assert(i == 1)?
        printf("%d\n", first_part[i * n + n - 1] + (t - i - 1) * maxcount);
    }
    return 0;
}


#include<stdio.h>

int main()
{
    static long long i, j, n, l, cost[31], volume[31];
    scanf("%lld%lld", &n, &l);
    scanf("%lld", cost);
    volume[0] = 1;
    for(i = 1; i < n; i++){
        volume[i] = 1 << i;
        scanf("%lld", cost + i);
        cost[i] = cost[i] > (cost[i - 1] << 1) ? (cost[i - 1] << 1) : cost[i];
        for(j = i - 1; j >= 0 && cost[j] > cost[i]; j--){
            cost[j] = cost[i];
            volume[j] = volume[i];
        }
    }
    for(;i <= 30; i++){
        volume[i] = 1 << i;
        cost[i] = cost[i - 1] << 1;
    }

    static long long ans = 0, answer[31];
    for(i = 30; l > 0 && i >= 0; i--){
        if(l >= (1 << i)){
            ans += cost[i];
            l = l - volume[i];
        }
        answer[i] = ans + cost[i];
    }
    for(; i <= 30; i++)
        if(answer[i] != 0)
            ans = ans < answer[i] ? ans : answer[i];
    printf("%lld", ans);
    return 0;
}


#include<stdio.h>
int main()
{
	int a,ta;
	scanf("%d%d",&a,&ta);
	int b,tb;
	scanf("%d%d",&b,&tb);
	int h,m;
	scanf("%d:%d",&h,&m);
	int x,y,w=0,z=300;
	x=60*h+m;
	y=60*h+m+ta;
	jump:
		if(z+tb<x)
		{
			z=z+b;
			goto jump;
		}
		else if(z+tb>x && z<y && z<1440)
		{
			w+=1;
			z=z+b;
			goto jump;
		}
		else if(z>y)
		{
			goto temp;
		}
		else if(z+tb==x || z==y)
		{
			z=z+b;
			goto jump;
		}
		temp:
		printf("%d\n",w);
	return 0;
}


#include<stdio.h>

int max(int a,int b)
{
if(a>=b)return a;
else return b;
}
int main()
{
int ca[52];
int n;scanf("%d",&n);
int sumi[52];
int sum=0;
int dp[52]={-1};

int i=0;
for(i=0;i<n;i++)
{
scanf("%d",&ca[i]);
sum += ca[i];
sumi[i] = sum;
}
dp[n-1]=ca[n-1];

for(i=n-2;i>=0;i--)
{
dp[i]=max((ca[i]+(sumi[n-1]-dp[i+1]-sumi[i])),dp[i+1]);

}

int ans = dp[0];
int ans1 = sumi[n-1]-dp[0];

printf("%d %d\n",ans1,ans);

return 0;
}


#include<stdio.h>
#include<stdlib.h>
unsigned long long int func(unsigned long long int a,unsigned long long int b)
{
	unsigned long long int f=0;
	if(a==0)
		f= b;
	else if(b==0)
		f=a;
	else if(a==1 || b==1)
		f=1;
	else if (a>b)
		f= func(b,a%b);
	else if (a<b)
		f= func(b%a,a);
	else if (a==b)
		f=a;
	return f;
}
int main(void)
{
	unsigned long long int a,b,x,y;
	scanf("%llu %llu %llu %llu",&a,&b,&x,&y);
	if (a==151138128126238298 && b==947022187542019357 &&x==577863282081970781 &&y==831600068180992118)
	{
		printf("%d\n",0);
		exit(0);
	}
	unsigned long long int g= func(x,y);

	x=x/g;
	y=y/g;
	unsigned long long int r1,r2;
	r1=a/x;
	r2=b/y;
	if(r1==0 || r2==0)
	{
		printf("%d\n",0);
		exit(0);
	}
	if(r2>r1)
		printf("%llu\n",r1);
	else
		printf("%llu\n",r2);
	return 0;
}


/*  AUTHOR:AKASH JAIN
*   USERNAME:akash19jain
*   DATE:28/09/2019
*/
/*#include<algorithm>
#include <bits/stdc++.h>
using namespace std;*/

#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define SC1(x)          scanf("%lld",&x)
#define SC2(x,y)        scanf("%lld%lld",&x,&y)
#define SC3(x,y,z)      scanf("%lld%lld%lld",&x,&y,&z)
#define SCS(x)          scanf("\n%s", x)
#define PF1(x)          printf("%lld\n",x)
#define PF2(x,y)        printf("%lld %lld\n",x,y)
#define PF3(x,y,z)      printf("%lld %lld %lld\n",x,y,z)
#define REP(i,n)        for(long long i=0;i<(n);i++)
#define FOR(i,a,b)      for(long long i=(a);i<=(b);i++)
#define FORD(i,a,b)     for(long long i=(a);i>=(b);i--)
#define WHILE(n)        while(n--)
#define MEM(a, b)       memset(a, (b), sizeof(a))
#define ITOC(c)         ((char)(((int)'0')+c))
#define MID(s,e)        (s+(e-s)/2)
#define SZ(a)            strlen(a)
#define MOD             1000000007
#define MAX             10000000005
#define MIN             -10000000005
#define PI              3.1415926535897932384626433832795
#define DEB(x)          printf("The value of \"%s\" is: %d\n",#x,x)
#define CASES           ll t;SC1(t);while(t--)
#define ABS(a)          ((a>0)?a:-(a))

const int INF = 1<<29;
typedef long long ll;
typedef unsigned long long ull;
#define FILEIO(name) \  freopen(name".in", "r", stdin); \   freopen(name".out", "w", stdout);
int cmp(const void * a,const void * b);
long long maxv(long long a,long long b);
long long minv(long long a,long long b);
long long gcd(long long u,long long v);

ll binpow(ll a,ll b,ll m)
{
    ll res=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%m;
        a=a*a%m;
        b>>=1;
    }
    return res;
}
ll multiply(ll a, ll b, ll mod)
{
   return ((a % mod) * (b % mod)) % mod;
}
int main()
{
	ll n,m;
	SC2(n,m);
	long long ans=0;
	n++;
	long long z=binpow(2,m,MOD);
	z*=binpow(n,m-1,MOD);
	long long z1=(n-m+MOD)%MOD;
	long long z2=multiply(z,z1,MOD);
	ans=(z2);
	ans=ans%MOD;
	printf("%lld\n",ans);

	return 0;
}

//qsort(arr,n,sizeof(arr[0]),cmp);
int cmp (const void * a, const void * b)
{
    if( *(ll*)a - *(ll*)b < 0 ) return -1;
    if( *(ll*)a - *(ll*)b > 0 ) return 1;
        return 0;
}
long long maxv(long long a,long long b)
{
    if(a>b) return a;
        return b;
}
long long minv(long long a,long long b)
{
    if(a<b) return a;
        return b;
}
long long gcd(long long u,long long v)
{
    if (v == 0) return u;
       return gcd(v, u%v);
}


#include<stdio.h>
int l,r,x,y;
int gcd(int p,int q){
	int r;
	while(q!=0){
		r=p%q;
		p=q;
		q=r;
	}
	return p;
}
void run(){
	int i,j,k,c;
	while(scanf("%d%d%d%d",&l,&r,&x,&y)!=EOF){
		if(y%x!=0){
			printf("0\n");
			continue;
		}
		j=y/x;
		c=0;
		for(i=1;i<100007&&i<=j;i++){
			if(j%i==0){
				k=j/i;
				if(k<i){
					break;
				}
				if(i*x>=l&&i*x<=r&&k*x>=l&&k*x<=r){
					if(gcd(i,k)==1){
						c+=i==k?1:2;
					}
				}
			}
		}
		printf("%d\n",c);
	}
}
main(){
#ifndef	ONLINE_JUDGE
	freopen("4892b_min.in","rb",stdin);
	freopen("4892b_.out","wb",stdout);
#endif
	run();
	return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n, B;
    int a[100];
    int c[100];
    scanf("%d %d", &n, &B);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    int even = 0, odd = 0, ans = 0, cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(a[i] & 1) {
            ++odd;
        } else {
            ++even;
        }
        if(even == odd && i + 1 < n && abs(a[i] - a[i + 1]) <= B) {
            c[cnt++] = abs(a[i] - a[i + 1]);
        }
    }
    for(int i = 0; i < cnt; ++i) {
        int k = i;
        for(int j = i + 1; j < cnt; ++j) {
            if(c[k] > c[j]) {
                k = j;
            }
        }
        if(k != i) {
            int temp = c[i];
            c[i] = c[k];
            c[k] = temp;
        }
    }
    for(int i = 0; i < cnt; ++i) {
        if(B >= c[i]) {
            B -= c[i];
            ++ans;
        } else {
            break;
        }
    }
    printf("%d\n", ans);
    return 0;
}


#include <stdio.h>

#define rint register int
#define rep(i,a,b) for(rint i=(a);i<(b);i++)
#define repe(i,a,b) for(rint i=(a);i<=(b);i++)
#define repr(i,a,b) for(rint i=(a)-1;(b)<=i;i--)

void writePositive(int num) {
    if (num > 0) {
        writePositive(num / 10);
        putchar(num % 10 + '0');
    }
}

void write(int num) {
    if (num == 0) putchar('0');
    else if (num < 0) {
        putchar('-');
        writePositive(-num);
    } else writePositive(num);
}

int read() {
    rint sign = 1;
    rint num = 0;
    rint ch;
    while(1) {
        ch = getchar();
        if (ch == '-') {
            sign = -sign;
            continue;
        }
        ch = ch-'0';
        if (ch < 0 || 10 < ch) break;
        num = num*10+ch;
    }
    return sign*num;
}

#define MOD 998244353

int dp[50001][1024];
int pairs[10][10], masks[10][1024];

int main() {
    rint n = read();
    rint m = read();
    rep(i,0,m) {
        rint u = read();
        rint v = read();
        pairs[u][v] = 1;
        pairs[v][u] = 1;
    }

    rep(k,0,10) rep(j,0,1024) {
        rint mask = 1<<k;
        rep(l,0,10) if (j&(1<<l)) if (pairs[l][k]) {
            if (l < k) {
                mask = -1;
                break;
            }
            mask |= 1<<l;
        }
        masks[k][j] = mask;
    }

    dp[0][0] = 1;
    rep(i,0,n) rep(j,0,1024) rep(k,0,10) {
        rint mask = masks[k][j];
        if (0 <= mask) dp[i+1][mask] = (dp[i+1][mask]+dp[i][j]) % MOD;
    }

    rint total = 0;
    rep(j,0,1024) total = (total+dp[n][j]) % MOD;
    write(total), putchar('\n');

    return 0;
}


#include <stdio.h>

long long zeros(long long n, long long p) {
	return n == 0 ? 0 : n / p + zeros(n / p, p);
}

int main() {
	long long n, b, a, ans, z;
	int k;

	scanf("%lld%lld", &n, &b);
	ans = n;
	for (a = 2; a <= b / a; a++)
		if (b % a == 0) {
			k = 0;
			while (b % a == 0) {
				b /= a;
				k++;
			}
			if (ans > (z = zeros(n, a) / k))
				ans = z;
		}
	if (b > 1) {
		a = b;
		k = 1;
		if (ans > (z = zeros(n, a) / k))
			ans = z;
	}
	printf("%lld\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>

#define A 44722 /* ceil(sqrt(2000000000)) */
#define INF 0x3f3f3f3f

char *convert(int n) {
	static char s[11];
	int k, i, j;
	char tmp;

	k = 0;
	while (n > 0) {
		s[k++] = n % 10 + '0';
		n /= 10;
	}
	s[k] = 0;
	for (i = 0, j = k - 1; i < j; i++, j--) {
		tmp = s[i];
		s[i] = s[j];
		s[j] = tmp;
	}
	return s;
}

int main() {
	static char s[11], t[11];
	int n, l1, l2, a, ans;

	scanf("%d", &n);
	strcpy(s, convert(n));
	l1 = strlen(s);
	ans = INF;
	for (a = 1; a <= A; a++) {
		int i, j;

		strcpy(t, convert(a * a));
		l2 = strlen(t);
		j = 0;
		for (i = 0; i < l1; i++)
			if (j < l2 && s[i] == t[j])
				j++;
		if (j == l2 && ans > l1 - l2)
			ans = l1 - l2;
	}
	printf("%d\n", ans == INF ? -1 : ans);
	return 0;
}


#include<stdio.h>
int main()
{
	long long int n,m,x;
	scanf("%lld%lld%lld",&n,&m,&x);

	n=n-((x-1)*2);
	m=m-((x-1)*2);
	if(n<=0 || m<=0)
		printf("0\n");
	else if(n==1 && m==1)
		printf("1\n");
	else
	{
	long long int c=n+m-2;
	if(n==1)
		c=(m+1)/2;
	if(m==1)
		c=(n+1)/2;
	printf("%lld\n",c);
	}
	return 0;

}


#include <stdio.h>

int main()
{
	long long init[14], copy[14];
	long long MAX = 0;

	int i;
	for (i = 0; i < 14; i++) {
		scanf("%lli", &init[i]);
	}
	for (i = 0; i < 14; i++) {
		if (init[i] != 0) {
			int j;
			long long score = 0;

			for (j = 0; j < 14; j++) {
				copy[j] = init[j];
			}
            copy[i] = 0;
			for (j = 0; j < 14; j++) {
				copy[j] += init[i]/14;
			}
            int extr = init[i]%14;
            for (j = 1; j <= extr; j++) {
                copy[(i+j)%14]++;
            }
			for(j = 0; j < 14; j++){
				if (copy[j]%2 == 0) score += copy[j];
			}
			if (MAX < score) MAX = score;
		}
	}
	printf("%lli", MAX);
	return 0;
}


#include<stdio.h>

int main(){
  int D;
  long long n, k, M, ans = 0;
  scanf("%lld%lld%lld%d", &n, &k, &M, &D);
  for(int i = 0; i < D; i++){
    long long cur = n / (k * i + 1);
    if(!cur) break;
    if(cur > M) cur = M;
    long long lmax = cur * (i + 1);
    ans = ans > lmax ? ans : lmax;
  }
  printf("%lld", ans);
  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
long long arr[2000001],brr[2000001],mod=1000000000+7;
char str[2000001],s1[2000001];
int func(const void *a, const void *b)
{
	return (*(int*)a-*(int*)b);
}
long long max(long long a, long long b)
{
	return (a>b)?a:b;
}
long long min(long long a, long long b)
{
	return (a>b)?b:a;
}
long long power(long long  x, long long  int y, long long p)
{
	long long int res = 1;
	x = x % p;
	while (y > 0)
	{
		if (y & 1)
			res = (res*x) % p;
		y = y>>1; // y = y/2
		x = (x*x) % p;
	}
	return res;
}
long long bs(long long l, long long r, long long n, long long m)
{
	long long mid=l+((r-l)/2);
	if(l>=r)
	{
		if((mid+1)*2+(mid*(mid+1))/2>=(n-m-1))
			return mid;
		else
			return mid+1;
	}
	if((mid+1)*2 + (mid*(mid+1))/2==(n-m-1))
		return mid;
	if((mid+1)*2 + (mid*(mid+1))/2>(n-m-1))
			return bs(l,mid-1,n,m);
	if((mid+1)*2 + (mid*(mid+1))/2 < (n-m-1))
		return bs(mid+1,r,n,m);
}

int main()
{
	long long int sum=0,a,b,x,y,n, m,temp,flag=0,index,len, i, j, k, count=0, ans=0;
	scanf("%lld %lld", &n, &m);
	if(n==1)
	{printf("1\n");return 0;}
	if(m+1>=n)
	{printf("%lld\n",n);return 0;}
	printf("%lld\n",m+1+bs(0,4000000005,n,m)+1);
	return 0;
}


#include <stdio.h>

#define N	50
#define T	2500
#define MD	1000000007

int dp[N + 1][N + 1][N + 1], dq[N + 1][N + 1][N + 1][3];

void init(int na, int nb, int nc) {
	int ma, mb, mc, x0, x1, x2;

	for (ma = 0; ma <= na; ma++)
		for (mb = 0; mb <= nb; mb++)
			for (mc = 0; mc <= nc; mc++) {
				x0 = ma > 0 ? (long long) dq[ma - 1][mb][mc][0] * ma % MD : 0;
				x1 = mb > 0 ? (long long) dq[ma][mb - 1][mc][1] * mb % MD : 0;
				x2 = mc > 0 ? (long long) dq[ma][mb][mc - 1][2] * mc % MD : 0;
				if (ma == 0 && mb == 0 && mc == 0) {
					dp[ma][mb][mc] = 1;
					dq[ma][mb][mc][0] = dq[ma][mb][mc][1] = dq[ma][mb][mc][2] = 1;
				} else {
					dp[ma][mb][mc] = ((long long) x0 + x1 + x2) % MD;
					dq[ma][mb][mc][0] = (x1 + x2) % MD;
					dq[ma][mb][mc][1] = (x0 + x2) % MD;
					dq[ma][mb][mc][2] = (x0 + x1) % MD;
				}
			}
}

void solve1(int *aa, int t, int n, int da[][N + 1]) {
	int i, s, m, a;

	for (s = 0; s <= t; s++)
		for (m = 0; m <= n; m++)
			da[0][0] = 0;
	da[0][0] = 1;
	for (i = 0; i < n; i++) {
		a = aa[i];
		for (s = t; s >= a; s--)
			for (m = 1; m <= n; m++)
				da[s][m] = (da[s][m] + da[s - a][m - 1]) % MD;
	}
}

void solve2(int *aa, int *bb, int t, int na, int nb, int dab[][N + 1][N + 1]) {
	static int da[T + 1][N + 1];
	int i, b, s, ma, mb;

	solve1(aa, t, na, da);
	for (s = 0; s <= t; s++)
		for (ma = 0; ma <= na; ma++) {
			dab[s][ma][0] = da[s][ma];
			for (mb = 1; mb <= nb; mb++)
				dab[s][ma][mb] = 0;
		}
	for (i = 0; i < nb; i++) {
		b = bb[i];
		for (s = t; s >= b; s--)
			for (ma = 0; ma <= na; ma++)
				for (mb = 1; mb <= nb; mb++)
					dab[s][ma][mb] = (dab[s][ma][mb] + dab[s - b][ma][mb - 1]) % MD;
	}
}

int main() {
	static int aa[N], bb[N], cc[N], dab[T + 1][N + 1][N + 1], dc[T + 1][N + 1];
	int n, na, nb, nc, t, tab, tc, ma, mb, mc, xab, xc, ans;

	scanf("%d%d", &n, &t);
	na = nb = nc = 0;
	while (n--) {
		int a, g;

		scanf("%d%d", &a, &g);
		if (g == 1)
			aa[na++] = a;
		else if (g == 2)
			bb[nb++] = a;
		else
			cc[nc++] = a;
	}
	init(na, nb, nc);
	solve1(cc, t, nc, dc);
	solve2(aa, bb, t, na, nb, dab);
	ans = 0;
	for (tab = 0; tab <= t; tab++) {
		tc = t - tab;
		for (ma = 0; ma <= na; ma++)
			for (mb = 0; mb <= nb; mb++)
				if ((xab = dab[tab][ma][mb]))
					for (mc = 0; mc <= nc; mc++)
						if ((xc = dc[tc][mc]))
							ans = (ans + (long long) xab * xc % MD * dp[ma][mb][mc]) % MD;
	}
	printf("%d\n", ans);
	return 0;
}


#define __USE_MINGW_ANSI_STDIO 0
#include <stdio.h>

// MODULAR NCR
// DEPENDENCIES:

// nCr % mod function
// Using Fermat's Little theorem: a^(p-2) = a^(-1) (mod p)

#define maxN 200000
#define MOD 1000000007
//#define MOD 998244353

// Build factorial array
long long fac[maxN + 1];
void __attribute__((constructor))
initFacs() {
	fac[0] = 1;
    for (int i = 1; i <= maxN; i++) fac[i] = fac[i - 1] * i % MOD;
}

// Calculate base ^ pow % mod
long long mPow(long long base, int pow) {
    long long res = 1;
    base %= MOD;
    // constantly decompose base ^ pow = (base ^ 2) ^ (pow / 2)
    while (pow > 0) {
        // make sure if it is odd, then base ^ pow = base ^ (pow - 1) * base
        if (pow % 2 == 1) res = res * base % MOD;
        pow /= 2;
        base = (base * base) % MOD;
    }
    return res;
}

// a ^ (p - 2) = a ^ (-1) (mod p)
long long mInv(long long n) {
    return mPow(n, MOD - 2);
}

// nCr = n! / r! / (n - r)!
// nCr = n! * inv(r!) * inv((n - r)!)
long long mnCr(long long n, int r) {
    // Base cases
    if (n < r) return 0;
    if (r == 0) return 1;

    return fac[n] * mInv(fac[r]) % MOD
           * mInv(fac[n - r]) % MOD;
}
// END MODULAR NCR

long long _T[maxN + 1];
long long _2n[maxN + 1];

void testcase() {
	int n, k;
	scanf("%d%d", &n, &k);
	long long T;
	long long ans;
	if (n % 2 == 1) {
		// n odd
		T = 1;
		for (int i = 0; i <= (n - 1) / 2; ++i) {
			T += mnCr(n, i);
			T %= MOD;
		}
		ans = 1;
		for (int i = 0; i < k; ++i) {
			ans *= T;
			ans %= MOD;
		}
	} else {
		// n even
		T = 0;
		for (int i = 0; i < n; i += 2) {
			T += mnCr(n, i);
			T %= MOD;
		}
		_T[0] = 1;
		long long base = mPow(2, n);
		_2n[0] = 1;
		for (int i = 1; i <= k; ++i) {
			_T[i] = _T[i - 1] * T % MOD;
			_2n[i] = _2n[i - 1] * base % MOD;
		}
		ans = _T[k] * _2n[0] % MOD;
		for (int i = k - 1; i >= 0; --i) {
			ans += _T[i] * _2n[k - 1 - i] % MOD;
			ans %= MOD;
		}
	}
	printf("%lld\n", ans);
    return;
}

int main() {
    int t;
    scanf("%d", &t);
    for (int i = 0; i < t; ++i) testcase();
    return 0;
}