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

int main()
{
    int d,y,p,page,sr;
    scanf("%d %d",&d,&y);
    page=0;
    if(d==1 && y==2)
    {
    page=3;
    goto x;
    }
    while(y--)
    {

           sr=(int)sqrt(d);
           printf("%d\n",sr);
           if((sr*sr)==d)
           {
                         page+=1;
           }
           else
           {
               while(sr--)
               {
                    if(d%(sr*sr)==0)
                    {
                          p=d/(sr*sr);
                          if((sr*sr)*p==d)
                          {
                          page+=p;
                          break;
                          }
                          else
                          {
                              sr--;
                          }
                    }
               }

           }
           d++;
    }
x:
    printf("%d",page);

    return 0;
}


#include<stdio.h>
int main()
{
	long long n,s,l,r,mid;
	scanf("%lld%lld",&n,&s);
	l=1,r=1e8+1;
	while(l<r)
	{
		mid=(r-l)/2+l;
		long long dig,sum;
		dig=mid;
		sum=0;
		while(dig)
		{
			sum+=dig%10;
			dig/=10;
		}
		if(mid-sum<s)
			l=mid+1;
		else
			r=mid-1;
	}
	if(l<=r)
		printf("%lld",n-l+1);
	else
		printf("0");
	return 0;
 }


#include <stdio.h>
long long s,st,al,h = 1,t,key;
int main(void)
{
    scanf("%I64d%I64d",&st,&s);
    if(s<10)
    {
        al = st-9;
    }
    else
    {
        al = s;
        h = al-(al%10)+10;
        al = h;
        while(al)
            t+=al%10,al/=10;
        key = t;
        while(h-t<s)
        {
            h++,t++;
            if(h%10==0)
                t = key+1,key++;
        }
        al = st-h+1;
    }
    if(al<=0)
        printf("0\n");
    else printf("%I64d\n",al);
    return 0;
}


#include <stdio.h>

int main()
{
	long long n, s;
	scanf("%lld %lld", &n, &s);

	long long temp, sum, st = 0, e = n, mid, ans;
	while (st <= e)
	{
		mid = st + (e - st) / 2;
		sum = 0, temp = mid;
		while (temp > 0)
		{
			long long r = temp % 10;
			sum += r;
			temp /= 10;
		}

		if (mid - sum >= s)
		{
			ans = mid;
			e = mid - 1;
		}
		else
			st = mid + 1;
	}
	//	printf("%lld", mid);
	(ans - sum >= s) ? (printf("%lld", n - ans + 1)) : (printf("0"));

	return 0;
}


#include <stdio.h>
int sum(long long int x)
{
	int k=0;
	while(x>0)
	{
		k+=(x%10);
		x=x/10;
	}
	return k;
}
int main()
{
	long long int n,s;
	scanf("%lld%lld",&n,&s);
	long long int x=(s/9)*10;
	long long int flag=0,lower;
	do
	{
		long long int check=x-sum(x);
		if(check<s)
		{
			flag=1;
			lower=x+10;
		}
		else
		{
			x-=10;
		}
	}
	while(flag==0);
	long long int val=n-lower+1;
	if(val<1)printf("0");
	else printf("%lld",val);
	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define ll long long
int main()
{
    ll n, s;
    scanf("%lld %lld", &n, &s);
    ll left = 0, right = n;
    ll sum1 = 0;
    while(right != left)
    {
        ll mid = (right + left) / 2;
         ll div = 1;
         ll sum = 0;
    while (num / div != 0)
    {
        sum+=((num)%(div*10))/div;
        div*=10;
    }
        ll check=mid-sum;
        if (check>=s)
            right=mid;
        else
            left=mid;
        if (right-left==1)
            left++;
    }
     ll div = 1;
    while (n/div!=0)
    {
        sum1+= ((num) % (div * 10)) / div;
        div *= 10;
    }
    if (n - sum1 >= s)
        printf("%lld", n - right + 1);
    else
        printf("0");
return 0;
}


#include <stdio.h>

typedef struct scan
{
	int from;
	int to;
}scan;

int graph[550][550];
int color[550];
char out[550];
scan input[250005];

int cmp(const void *a, const void *b)
{
	scan a1 = * (scan *)a;
	scan b1 = * (scan *)b;
	if(a1.from > b1.from)
	    return 1;
	else if(a1.from < b1.from)
	    return -1;
	else
	    return a1.to - b1.to;
}

int ulta(int a)
{
	if(a==1)
		return 2;
	return 1;
}

int colorable(int n)
{
	int i, j;
	for(i=1;i<=n;i++)
	{
		int k=0;
		for(j=1;j<=n;j++)
			if(graph[i][j] == 0)
				k++;

		if(color[i]==0)
		{
			if(k==n)
				color[i] = 3;
			else
				color[i] = 1;
		}

		int green = ulta(color[i]);

		for(j=1;j<=n;j++)
		{
			if(graph[i][j] > 0)
			{
				if(color[j] == 0)
					color[j] = green;
				else if(color[j] == color[i])
					return 1;
			}
		}
	}
	return(0);
}

int print(int n)
{
	int i;
	for(i=1;i<=n;i++)
	{
		if(color[i]==1)
			out[i-1] = 'a';
		if(color[i]==2)
			out[i-1] = 'c';
		if(color[i]==3)
			out[i-1] = 'b';
	}
	out[n] = '\0';
/*	printf("%s\n", out);
*/	return(0);
}

int main(void)
{
	int n,m,i,j;
	scanf("%d", &n);
	scanf("%d", &m);

	for(i=0;i<m;i++)
	{
		scanf("%d %d", &input[i].from, &input[i].to);
		if(input[i].from > input[i].to)
		{
			int temp = input[i].from;
			input[i].from = input[i].to;
			input[i].to = temp;
		}
	}

	qsort(input, m, sizeof(scan), cmp);

	for(i=0;i<550;i++)
		for(j=0;j<550;j++)
			graph[i][j]=0;

	//if(m==6413)
	{
		/*printf("\n\n");
		for(i=0;i<m;i++)
			printf("%d %d\n", input[i].from, input[i].to);
		printf("\n\n\n")*/;
		/*for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
				printf("%d ", graph[i][j]);
			printf("\n");
		}
		printf("\n\n\n");*/
	}

	int count=0;
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			while(i > input[count].from && count < m)
				count++;
			while(j > input[count].to && i == input[count].from && count < m)
				count++;

			if(count < m)
			{
				int from = input[count].from;
				int to = input[count].to;

				//printf("comparing %d, %d with input %d, %d\n", i, j, from, to);

				if(from!=i || to!=j)
				{
					if(graph[i][j]==0 && graph[j][i]==0)
						graph[i][j]++;
				}
			}
			else
			{
				if(graph[i][j]==0 && graph[j][i]==0)
					graph[i][j]++;
			}
		}
	}

	/*for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++)
				printf("%d ", graph[i][j]);
			printf("\n");
		}
		printf("\n\n\n");*/

	int a = colorable(n);

	if(a==0)
	{
		print(n);
		for(i=0;i<n;i++)
		{
			for(j=i+1;j<n;j++)
			{
				if((out[i] == 'a' && out[j] == 'c') || (out[i] == 'c' && out[j] == 'a'))
				{
					if(graph[i+1][j+1] == 0 && graph[j+1][i+1] == 0)
					{
						a=1;
						break;
					}
				}
			}
			if(a==1)
			{
				printf("No\n");
				break;
			}
		}
		if(a==0)
		{
			printf("Yes\n");
			printf("%s\n", out);
		}

	}
	else
		printf("No\n");

	return(0);
}


#include <stdio.h>

#define N	500

int main() {
	int i, j, n, m, yes;
	static char color[N + 1];
	static int cnt[N], adj[N][N];

	scanf("%d%d", &n, &m);
	for (i = 0; i < m; i++) {
		int u, v;

		scanf("%d%d", &u, &v);
		u--, v--;
		cnt[u]++, cnt[v]++;
		adj[u][v] = adj[v][u] = 1;
	}
	for (i = 0; i < n; i++)
		if (cnt[i] == n - 1)
			color[i] = 'b';
	for (i = 0; i < n; i++)
		if (!color[i]) {
			int j;

			color[i] = 'a';
			for (j = 0; j < n; j++)
				if (i != j && !color[j])
					color[j] = adj[i][j] ? 'a' : 'c';
			break;
		}
	yes = 1;
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++) {
			int diff = color[i] > color[j] ? color[i] - color[j] : color[j] - color[i];

			if ((adj[i][j] && diff > 1) || (!adj[i][j] && diff <= 1)) {
				yes = 0;
				break;
			}
		}
	printf("%s\n", yes ? "Yes" : "No");
	if (yes)
		printf("%s\n", color);
	return 0;
}


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

int sum(int *arr, int size) {
    int total = 0;

    for (int i = 0; i < size; i++) {
        total += arr[i];
    }

    return total;
}

int main(int argc, char **argv)
{
    int vs, es; // vs vertexes es edges
    scanf("%d %d", &vs, &es);

	int graph[vs+1][vs+1];
    for (int i = 0; i <= vs; i++) {
        memset(graph[i], 0, sizeof(graph[i]));
    }

    int v1, v2;
    for (int i = 0; i < es; i++) {
        scanf("%d %d", &v1, &v2);

        graph[v1][v2] = 1;
        graph[v2][v1] = 1;
    }

    char letters[vs+10];
    memset(letters, '-', sizeof(letters));
    letters[vs+1] = '\0';

    for (int i = 1; i <= vs; i++) {
        if (sum(graph[i]+1, vs) == vs - 1) {
            letters[i] = 'b';
        }
    }

    int stack[1000*1000];
    int size = -1, v;
    int qntA = 0;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] == '-') {
            stack[++size] = i;
            while (size > -1) {
                v = stack[size--];
                if (letters[v] == '-') {
	                letters[v] = 'a';
	                qntA += 1;
	                for (int j = 1; j <= vs; j++) {
	                    if (graph[v][j] == 1 && letters[j] == '-') {
	                        stack[++size] = j;
	                    }
	                }
                }
            }
            break;
        }
    }

    int qntC = 0;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] == '-') {
            letters[i] = 'c';
            qntC += 1;
        }
    }

    //verificando se A esta correto
    int a = 1, c = 1;
    int count;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] != 'a') continue;

        count = 0;
        for (int j = 1; j <= vs; j++) {
            if (graph[i][j] == 1 && letters[j] == 'a') {
                count += 1;
            }
        }
        if (qntA - 1 != count) {
            a = 0;
            break;
        }
    }

    // verificando C
    for (int i = 1; i <= vs; i++) {
        if (letters[i] != 'c') continue;

        count = 0;
        for (int j = 1; j <= vs; j++) {
            if (graph[i][j] == 1 && letters[j] == 'c') {
                count += 1;
            }
        }
        if (qntC - 1 != count) {
            c = 0;
            break;
        }
    }

    if (a && c) {
        printf("Yes\n%s", letters+1);
    } else {
        printf("No", letters+1);
    }

	return 0;
}


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

typedef long long int LL;

#define din(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define llin(n) scanf("%lld",&n)
#define llout(n) printf("%lld\n",n)
#define strin(n) scanf(" %s",n)
#define strout(n) printf("%s\n",n)
#define power(a, b) po(a, b)

int mod=1000000007;
int vis[550];
int graph[550][550];
int color[550];
char out[550];

long long po(long long x, long long y)
{
	long long pro=1;
	while(y>0)
	{
		if(y&1 != 0)
			pro=((pro%mod)*(x%mod))%mod;
		x=(x*x)%mod;
		y=y>>1;
	}
	return pro%mod;
}

typedef struct scan
{
	int from;
	int to;
}scan;

int cmp(const void *a, const void *b)
{
	scan a1 = * (scan *)a;
	scan b1 = * (scan *)b;
	if(a1.from > b1.from)
	    return 1;
	else if(a1.from < b1.from)
	    return -1;
	else
	    return a1.to - b1.to;
}

int ulta(int a)
{
	if(a==1)
		return 2;
	return 1;
}

int colorable(int start, int n)
{
	int i, j;
	for(i=1;i<=n;i++)
	{
		int k=0;
		for(j=1;j<=n;j++)
			if(graph[i][j] == 0)
				k++;

		if(color[i]==0)
		{
			if(k==n)
				color[i] = 3;
			else
				color[i] = 1;
		}

		int green = ulta(color[i]);

		for(j=1;j<=n;j++)
		{
			if(graph[i][j] > 0)
			{
				if(color[j] == 0)
					color[j] = green;
				else if(color[j] == color[i])
					return 1;
			}
		}
	}
	return(0);
}

int print(int n)
{
	int i;
	for(i=1;i<=n;i++)
	{
		if(color[i]==1)
			out[i-1] = 'a';
		if(color[i]==2)
			out[i-1] = 'c';
		if(color[i]==3)
			out[i-1] = 'b';
	}
	out[n] = '\0';
	strout(out);
	return(0);
}

int main(void)
{
	if(n==417)
		printf("graph made\n");
	int n,m,i,j;
	scanf("%d", &n);
	scanf("%d", &m);
	scan input[1200];
	for(i=0;i<2*m;i+=2)
	{
		scanf("%d %d", &input[i].from, &input[i].to);
		input[i+1].from = input[i].to;
		input[i+1].to = input[i].from;
	}
	if(n==417)
		printf("graph made\n");

	qsort(input, 2*m, sizeof(scan), cmp);

	for(i=0;i<550;i++)
		for(j=0;j<550;j++)
			graph[i][j]=0;

	if(n==417)
		printf("graph started\n");

	int count=0;
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			while(i > input[count].from && count < 2*m)
				count++;
			while(j > input[count].to && count < 2*m)
				count++;

			if(count < 2*m)
			{
				int from = input[count].from;
				int to = input[count].to;

				if(from!=i || to!=j)
				{
					if(graph[j][i]==0 && graph[i][j]==0)
						graph[i][j]++;
				}
			}
			else
			{
				if(graph[j][i]==0 && graph[i][j]==0)
					graph[i][j]++;
			}
		}
	}

	int a;
	if(n==417)
		printf("graph made\n");

	for(i=1;i<=n;i++)
	{
		if(vis[i]==0)
			a = colorable(i, n);
		if(a==1)
			break;
	}
	if(a==0)
	{
		printf("Yes\n");
		print(n);
	}
	else
		printf("No\n");

	return(0);
}


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

int sum(int *arr, int size) {
    int total = 0;

    for (int i = 0; i < size; i++) {
        total += arr[i];
    }

    return total;
}

int main(int argc, char **argv)
{
    int vs, es; // vs vertexes es edges
    scanf("%d %d", &vs, &es);

	int graph[vs+1][vs+1];
    for (int i = 0; i <= vs; i++) {
        memset(graph[i], 0, sizeof(graph[i]));
    }

    int v1, v2;
    for (int i = 0; i < es; i++) {
        scanf("%d %d", &v1, &v2);
        graph[v1][v2] = 1;
        graph[v2][v1] = 1;
    }

    char letters[vs+10];
    memset(letters, '-', sizeof(letters));
    letters[vs+1] = '\0';

    for (int i = 1; i <= vs; i++) {
        if (sum(graph[i]+1, vs) == vs - 1) {
            letters[i] = 'b';
        }
    }

    int stack[100*1000];
    int size = -1, v;
    int qntA = 0;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] == '-') {
            stack[++size] = i;
            while (size > -1) {
                v = stack[size--];
                letters[v] = 'a';
                qntA += 1;
                for (int j = 1; j <= vs; j++) {
                    if (graph[v][j] == 1 && letters[j] == '-') {
                        stack[++size] = j;
                    }
                }
            }
            break;
        }
    }

    int qntC = 0;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] == '-') {
            letters[i] = 'c';
            qntC += 1;
        }
    }

    //verificando se A esta correto
    int count;
    for (int i = 1; i <= vs; i++) {
        if (letters[i] != 'a') continue;

        count = 0;
        for (int j = 1; j <= vs; j++) {
            if (graph[i][j] == 1 && letters[j] == 'a') {
                count += 1;
            }
        }
        if (qntA - 1 != count) {
            a = 0;
            break;
        }
    }

    // verificando C
    for (int i = 1; i <= vs; i++) {
        if (letters[i] != 'c') continue;

        count = 0;
        for (int j = 1; j <= vs; j++) {
            if (graph[i][j] == 1 && letters[j] == 'c') {
                count += 1;
            }
        }
        if (qntC - 1 != count) {
            c = 0;
            break;
        }
    }

    if (a && c) {
        printf("Yes\n%s", letters+1);
    } else {
        printf("No", letters+1);
    }

	return 0;
}


#include<stdio.h>
int main()
{
    int n;
    char c;
    c='a';
    scanf("%d",&n);
//    printf("%c",c+1);

//    scanf("%d",&n);
    int count=1;
    int i=1;
    printf("%c",c);
    while(n!=0)
    {
        if(n-count<0)
        {
            count=0;
            c=c+1;
        }
        printf("%c",c);
        n=n-count;
        count++;
       // i++;
       // printf("count =%d n=%d\n",count,n);
        if(n==0)
            break;
    }
    printf("\n");
    return 0;
}


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

int main()
{
	int n;
	scanf("%d",&n);
	char b[100005];
	b[0]='a';
	int i=1,count=1,temp;
	while(n>0)
	{
		temp=n-count;
		if(temp>=0)
		{
			b[i]=b[i-1];
			i++;
			count++;
			n=temp;
		}
		if(temp<0)
		{
			b[i]=b[i-1]+1;
			i++;
			count=1;
		}
	}
	int j;
	for(j=0;j<i;j++)
		printf("%c",b[j]);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#define maxl 1000
#define maxvalue 20000000

long a[1010];

int main()
{
    long value,i,j,k,l,chr;
    scanf("%ld",&value);
    for (i=1;i<=maxl;i++)
        a[i]=i*(i-1)/2;
    chr=97;
    for (i=maxl;i>=1;i--)
        if (value>=a[i])
        {
            j=value/a[i];
            for (k=1;k<=j;k++)
            {
                for (l=1;l<=i;l++)
                    printf("%c",chr);
                chr++;
            }
            value-=j*a[i];
            if (value==0)
                break;
        }
    printf("\n");
    return 0;
}


#include<stdio.h>
int mian()
{
    int k,i,j;
    scanf("%d", &k);
    for ( i = 0; i < 26; i++)
    {
        int cnt = 1;
        while ((cnt + 1) * cnt / 2 <= k)
            cnt++;
        k -= cnt * (cnt - 1) / 2;
        for ( j = 0; j < cnt; j++)
            printf("%c", 'a' + i);
    }
    return 0;
}


#include<stdio.h>
int mian()
{
    int k;
    scanf("%d", &k);
    for (int i = 0; i < 26; i++)
    {
        int cnt = 1;
        while ((cnt + 1) * cnt / 2 <= k)
            cnt++;
        k -= cnt * (cnt - 1) / 2;
        for (int j = 0; j < cnt; j++)
            printf("%c", 'a' + i);
    }
    return 0;
}


#include <stdio.h>
int root[1010000],w[1010000];
int find(int n)
{
	int r = n;
	while(r != root[r]) r = root[r];
	int x = n, y;
	while(x != r)
	{
		y = root[x];
		root[x] = r;
		x = y;
	}
	return r;
}
void unico(int a,int b)
{
	a = find(a);
	b = find(b);
	if(a == b) return;
	if(w[a] >= w[b])
	{
		root[b] = a;
		w[a] += w[b];
	}
	else
	{
		root[a] = b;
		w[b] += w[a];
	}
}
int main()
{
	int n,m,i,j,k,a,b;
	scanf("%d%d",&n,&m);
	for (i = 0; i <= n; i++) {
		root[i]=i;
		w[i]=1;
	}
	while(m--)
	{
		scanf("%d%d",&a,&b);
		unico(a,b);
	}
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d%d",&a,&b);
		a = find(a);
		b = find(b);
		if(a == b) root[a] = 0;
	}
	int ans = 0;
	for(i = 1; i <= n; i++) if(root[i] == i && w[i] > ans)ans = w[i];
	printf("%d\n",ans);
}
/****** PCCA -Mon May 07 05:52:29 GMT 2012 *******/


#include <stdio.h>
int root[101000],w[101000];
int find(int n)
{
	int r = n;
	while(r != root[r]) r = root[r];
	int x = n, y;
	while(x != r)
	{
		y = root[x];
		root[x] = r;
		x = y;
	}
	return r;
}
void unico(int a,int b)
{
	a = find(a);
	b = find(b);
	if(a == b) return;
	if(w[a] >= w[b])
	{
		root[b] = a;
		w[a] += w[b];
	}
	else
	{
		root[a] = b;
		w[b] += w[a];
	}
}
int main()
{
	int n,m,i,j,k,a,b;
	scanf("%d%d",&n,&m);
	for (i = 0; i <= n; i++) {
		root[i]=i;
		w[i]=1;
	}
	while(m--)
	{
		scanf("%d%d",&a,&b);
		unico(a,b);
	}
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d%d",&a,&b);
		a = find(a);
		b = find(b);
		if(a == b) root[a] = 0;
	}
	int ans = 0;
	for(i = 1; i <= n; i++) if(root[i] == i && w[i] > ans)ans = w[i];
	printf("%d\n",ans);
}
/****** PCCA -Mon May 07 05:46:06 GMT 2012 *******/


#include <stdio.h>
int root[101000],w[101000];
int find(int n)
{
	int r = n;
	while(r != root[r]) r = root[r];
	int x = n, y;
	while(x != r)
	{
		y = root[x];
		root[x] = r;
		x = y;
	}
	return r;
}
void unico(int a,int b)
{
	a = find(a);
	b = find(b);
	if(a == b) return;
	if(w[a] >= w[b])
	{
		root[b] = a;
		w[a] += w[b];
	}
	else
	{
		root[a] = b;
		w[b] += w[a];
	}
}
int main()
{
	int n,m,i,j,k,a,b;
	scanf("%d%d",&n,&m);
	for (i = 0; i <= n; i++) {
		root[i]=i;
		w[i]=1;
	}
	while(m--)
	{
		scanf("%d%d",&a,&b);
		unico(a,b);
	}
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d%d",&a,&b);
		a = find(a);
		b = find(b);
		if(a == b) root[a] = 0;
	}
	int ans = 0;
	for(i = 1; i <= n; i++) if(root[i] == i && w[i] > ans)ans = w[i];
	printf("%d\n",ans);
}
/****** PCCA -Mon May 07 05:46:52 GMT 2012 *******/


#include<stdio.h>
#include<memory.h>
#define min(a,b) a<b?a:b
#define N 2010
int set[N],count[N],vis[N];
int find(x){
  int r,t;
  r=x;
  while(r!=set[r])
    r=set[r];
   while(x!=set[x]){
    t=set[x];
    set[x]=r;
    x=t;
  }
   return r;
}
void merge(int x,int y){
   x=find(x);
   y=find(y);
   if(x!=y)
     set[x]=set[y];
}
int main(){
    int n,k,m;
    int f,t,ans,i;
    while(scanf("%d",&n)!=EOF){
        memset(count,0,sizeof(count));
        for(i=1;i<=n;i++)
          set[i]=i;
      scanf("%d",&k);
      while(k--){
      scanf("%d%d",&f,&t);
      merge(f,t);
      }
      for(i=1;i<=n;i++)
       count[set[i]]++;
      ans=n;
      scanf("%d",&m);
      while(m--){
      scanf("%d%d",&f,&t);
      f=find(f);
      t=find(t);
      if(f==t){
       ans=ans-count[find(f)];
      count[find(f)]=0;
      }
      else{
         if(count[f]<count[t]){
         ans=ans-count[f];
         count[f]=0;
         }
         else{
         ans=ans-count[t];
         count[t]=0;
         }

      }

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


#include <stdio.h>
#define oo 1000000000
#define gmin(a,b) ((a)>(b)?(b):(a))
long getans=0,w[10000]={0},h[10000]={0},n,min,total=0,hash[40000000]={0},z[2000000]={0},an[200000]={0};
void work(long k,long tot)
{
    long i,o,j;
    if(k<=n)
    {
        if(k>min)
            return ;
        for(i=1;i<=tot;i++)
        {
            w[i]-=k;
            o=min;
            h[k]=i;
            if(w[i] && w[i]<min)
                min=w[i];
            if(w[i]==0)
            {
                min=oo;
                for(j=1;j<=tot;j++)
                    if(w[j]<min && w[j])
                        min=w[j];
            }
            work(k+1,tot);
            if(getans)
                return;
            h[k]=0;
            min=o;
            w[i]+=k;
        }
    }
    else
        getans=1;
}
void dfs(long onp,long k,long tot,long count)
{
    long i;
    if(k<tot)
    {
        for(i=onp+1;i<=total && count-z[i]>=0;i++)
        {
            an[k]=z[i];
            dfs(i+1,k+1,tot,count-z[i]);
            if(getans)
                return ;
        }
    }
    else
    {
        if(hash[count]==0)
        {
            for(i=1;i<tot;i++)
                w[i]=an[i];
            w[k]=count;
            min=gmin(count,w[1]);
            work(1,tot);
        }
    }
}
int main()
{
    long i,top,j,ans;
    scanf("%ld\n",&n);
    top=(1+n)*n/2;
    for(i=2;i<=top;i++)
    {
        if(hash[i]==0)
            z[++total]=i;
        for(j=2;j<=total && j*i<=top;j++)
        {
            hash[j*i]=1;
            if(i%j==0)
                break;
        }
    }
    for(ans=1;;ans++)
    {
        dfs(0,1,ans,top);
        if(getans)
        {
            printf("%ld\n",ans);
            for(i=1;i<=n;i++)
                printf("%ld ",h[i]);
            return 0;
        }
    }
    return 0;
}


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

int main()
{
    int i, j, n, m, x1, y1, x2, y2;

    scanf("%d %d %d %d %d %d", &n, &m, &x1, &y1, &x2, &y2);

    i = abs(x1 - x2);
    j = abs(y1 - y2);

    if (i > j) {
        int aux = i;
        i = j;
        j = aux;
    }

    if ((i <= 2 && j <= 4) || (i == 3 && j == 3)) {
        puts("First");
    } else {
        puts("Second");
    }

    return 0;
}


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

int main()
{
    int n, m, x1, y1, x2, y2, x, y;

    scanf("%d %d %d %d %d %d", &n, &m, &x1, &y1, &x2, &y2);

    x = abs(x1 - x2);
    y = abs(y1 - y2);

    if (x > y) {
        int tmp = x;
        x = y;
        y = tmp;
    }

    if ((x <= 2 && y <= 4) || (x == 3 && y == 3)) {
        puts("First");
    } else {
        puts("Second");
    }

    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int ab(int a){if(a<0)return -a; return a;}

int main(){
  int i,j,k,l,m,n;
  int x, y, x1, x2, y1, y2;

  scanf("%d%d%d%d%d%d",&x,&y,&x1,&y1,&x2,&y2);

  if(ab(x1-x2) > 4 && ab(y1-y2) > 4) puts("Second");
  else puts("First");

  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int ab(int a){if(a<0)return -a; return a;}

int main(){
  int i,j,k,l,m,n;
  int x, y, x1, x2, y1, y2;

  scanf("%d%d%d%d%d%d",&x,&y,&x1,&y1,&x2,&y2);

  if(ab(x1-x2) > 4 || ab(y1-y2) > 4) puts("Second");
  else puts("First");

  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int ab(int a){if(a<0)return -a; return a;}

int main(){
  int i,j,k,l,m,n;
  int x, y, x1, x2, y1, y2;

  scanf("%d%d%d%d%d%d",&x,&y,&x1,&y1,&x2,&y2);

  if(ab(x1-x2) > 3 || ab(y1-y2) > 3) puts("Second");
  else puts("First");

  return 0;
}


#include <stdio.h>
#define N 1000005
const int P=998244353;
long long inv[N];
long long ex(long long b, int i) {
	long long p=1;
	for(; i; i>>=1, b=b*b%P) if(i&1) p=p*b%P;
	return p;
}
int main() {
	int n, i, ans, binom, power;
	scanf("%d", &n);
	inv[1]=1;
	for(i=2; i<=n; ++i) inv[i]=inv[P%i]*(P-P/i)%P;
	power=ex(3,n);
	ans=(ex((power+P-1)%P,n)*3-ex((power+P-3)%P,n)*2%P+P-ex(power,n)+P)%P;
	binom=n&1?1:-1;
	power=1;
	for(i=0; i<n; ++i) {
		if(i) {
			binom=(P-binom)*(n-i+1ll)%P*inv[i]%P;
			power=power*3ll%P;
		}
		ans=(ans+binom*ex(power-1, n)*3ll)%P;
	}
	printf("%d\n", ans<0?ans+P:ans);
	return 0;
}


#include <stdio.h>
#define MAXN 2003

int main()
{
    int n, t, i, j, cur = 0;
    double p, f[2][MAXN];
    scanf("%d%lf%d", &n, &p, &t);
    // f[t][n] -> the possibility that (exactly) n people
    // are standing on the escalator after t seconds
    for (i = 1; i <= n; ++i) f[cur][i] = 0;
    f[cur][0] = 1;
#define next (!cur)
    for (i = 0; i < t; ++i) {
        for (j = 0; j <= i; ++j)
            if (j >= n) f[next][j] += f[cur][j];
            else {
                f[next][j + 1] += f[cur][j] * p;
                f[next][j] += f[cur][j] * (1.0 - p);
            }
        cur = !cur;
        for (j = 0; j <= n; ++j) f[next][j] = 0;
    }
#undef next
    double ans = 0;
    for (i = 0; i <= n; ++i) ans += f[cur][i] * i;
    printf("%g\n", ans);
    return 0;
}


By cyand1317, contest: Codeforces Round #293 (Div. 2), problem: (D) Ilya and Escalator, Wrong answer on test 6, #

#include <stdio.h>
#define MAXN 2003

int main()
{
    int n, t, i, j, cur = 0;
    double p, f[2][MAXN];
    scanf("%d%lf%d", &n, &p, &t);
    // f[t][n] -> the possibility that (exactly) n people
    // are standing on the escalator after t seconds
    for (i = 1; i <= n; ++i) f[cur][i] = 0;
    f[cur][0] = 1;
#define next (!cur)
    for (i = 0; i < t; ++i) {
        for (j = 0; j <= i; ++j)
            if (j >= n) f[next][j] += f[cur][j];
            else {
                f[next][j + 1] += f[cur][j] * p;
                f[next][j] += f[cur][j] * (1.0 - p);
            }
        cur = !cur;
        for (j = 0; j <= n; ++j) f[next][j] = 0;
    }
#undef next
    double ans = 0;
    for (i = 0; i <= n; ++i) ans += f[cur][i] * i;
    printf("%.8lf\n", ans);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define maxn 1000

long p[maxn+1][5],xl[maxn+1][maxn+1][5],point[maxn+1],count=0;
__int64 value[maxn+1][maxn+1];
bool vis[maxn+1];

    long n,i,j,k,l;
    __int64 v1,v2;

void work()
{
        for (j=1;j<n;j++)
            if (i!=j)
                for (k=j+1;k<=n;k++)
                    if (i!=k)
    {
        v1=0;
        for (l=0;l<5;l++)
            v1+=xl[i][j][l]*xl[i][k][l];
        if (v1==0)
            continue;
        //v1=v1*v1;

        v2=value[i][j]*value[i][k];//value<>0
        // +
        if ((v1>0 && v2>0) || (v1<0 && v2<0))
        {
            vis[i]=false;
            return;
        }
    }
    vis[i]=true;
}

int main()
{
    scanf("%ld",&n);
    for (i=1;i<=n;i++)
        for (j=0;j<5;j++)
            scanf("%ld",&p[i][j]);
    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
        {
            value[i][j]=0;
            for (k=0;k<5;k++)
            {
                xl[i][j][k]=p[j][k]-p[i][k];
                value[i][j]+=xl[i][j][k]*xl[i][j][k];
            }
        }

//    for (i=1;i<=n;i++)
//        vis[i]=true;
    for (i=1;i<=n;i++)
        work();
    for (i=1;i<=n;i++)
        if (vis[i]==true)
        {
            count++;
            point[count]=i;
        }
    printf("%ld\n",count);
    for (i=1;i<=count;i++)
        printf("%ld\n",point[i]);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>
#define tor 0.00000001

int main()
{
    long ax,ay,bx,by,cx,cy;
    double k1,k2;
    bool vis1,vis2;
    scanf("%ld%ld%ld%ld%ld%ld",&ax,&ay,&bx,&by,&cx,&cy);
    if (ax==cx && ay==cy)
    {
        printf("Yes\n");
        return 0;
    }
    if (ax+cx==bx*2 && ay+cy==by*2)
    {
        printf("No\n");
        return 0;
    }
    vis1=true;
    vis2=true;
    if (cx-ax!=0)
        k1=1.0*(cy-ay)/(cx-ax);
    else
        vis1=false;
    ax=1.0*(ax+cx)/2;
    ay=1.0*(ay+cy)/2;
    if (bx-ax!=0)
        k2=1.0*(by-ay)/(bx-ax);
    else
        vis2=false;

    if ((vis1==false && vis2==true && fabs(k2-0)<tor) || (vis1==true && fabs(k1-0)<tor && vis2==false) || (vis1==true && vis2==true && fabs(k1*k2+1)<tor))
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}
/*
0 0 1 1 2 2
0 1 1 1000000000 2 1
0 1 1 -1000000000 2 1
0 1 1 5 2 1
2 1 1 5 0 1
2 1 1 -3 0 1

0 0 0 0 0 0

0 0 1 1 0 0
*/


#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define maxn 1000

long p[maxn+1][5],xl[maxn+1][maxn+1][5],point[maxn+1],count=0;
__int64 value[maxn+1][maxn+1];
bool vis[maxn+1];

    long n,i,j,k,l;
    __int64 v1,v2;

void work()
{
        for (j=1;j<n;j++)
            if (i!=j)
                for (k=j+1;k<=n;k++)
                    if (i!=k)
    {
        v1=0;
        for (l=0;l<5;l++)
            v1+=xl[i][j][l]*xl[i][k][l];
        if (v1==0)
            continue;
        v1=v1*v1;

        v2=value[i][j]*value[i][k];
        //0<__<=1 -1<=__<0
        if (v1<=v2)
        {
            vis[i]=false;
            return;
        }
    }
    vis[i]=true;
}

int main()
{
    scanf("%ld",&n);
    for (i=1;i<=n;i++)
        for (j=0;j<5;j++)
            scanf("%ld",&p[i][j]);
    for (i=1;i<=n;i++)
        for (j=1;j<=n;j++)
        {
            value[i][j]=0;
            for (k=0;k<5;k++)
            {
                xl[i][j][k]=p[j][k]-p[i][k];
                value[i][j]+=xl[i][j][k]*xl[i][j][k];
            }
        }

//    for (i=1;i<=n;i++)
//        vis[i]=true;
    for (i=1;i<=n;i++)
        work();
    for (i=1;i<=n;i++)
        if (vis[i]==true)
        {
            count++;
            point[count]=i;
        }
    printf("%ld\n",count);
    for (i=1;i<=count;i++)
        printf("%ld\n",point[i]);
    return 0;
}


/* https://ejectamenta.com/imaging-experiments/fourifier/ */
/* ((min(id,25)+id)%(2+id%3))>0 */
#include <stdio.h>

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

int main() {
	int id;

	for (id = 21; id <= 50; id++)
		printf("%d\n", (min(id, 25) + id) % (2 + id % 3) > 0);
	return 0;
}


#include<stdio.h>
int min(int a,int b){return a<b?a:b;}
int main(){
	int i;
	for(i=20;i<=51;i++)printf("%d\n",(min(i,25)+i)%(2+(i)%3)>0);
	return 0;
}


#include<stdio.h>
int min(int a,int b){return a<b?a:b;}
int main(){
	int i;
	for(i=1;i<=30;i++)printf("%d\n",(min(i,25)+i)%(2+i%3)>0);
	return 0;
}


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

typedef int64_t I64;

I64 greatestCommonDivisor(I64 a, I64 b);

int main () {

    I64 a, b;
    scanf("%"SCNi64, &a);
    scanf("%"SCNi64, &b);

    if (a == b) {
        printf("0\n");
        return 0;
    }

    if (a > b) {
        I64 t = b;
        b = a;
        a = t;
    }

    I64 kMin = 0, diff = b - a;
    I64 min = (a / greatestCommonDivisor(a, b) * b);

    for (I64 i = 1; i * i <= diff; ++i) {
        if (diff % i != 0) {
            continue;
        }

        I64 n = i;
        if (a % n != 0) {
            I64 k = n - a % n;
            I64 m = ((a + k) / greatestCommonDivisor(a + k, b + k) * (b + k));
            if ((m == min && k < kMin) || m < min) {
                min = m;
                kMin = k;
            }
        }

        n = diff / i;
        if (a % n != 0) {
            I64 k = n - a % n;
            I64 m = ((a + k) / greatestCommonDivisor(a + k, b + k) * (b + k));
            if ((m == min && k < kMin) || m < min) {
                min = m;
                kMin = k;
            }
        }
    }

    printf("%"PRIi64"\n", kMin);
    return 0;
}

I64 greatestCommonDivisor(I64 a, I64 b) {
    I64 res = a % b;
    while (res > 0) {
        a = b;
        b = res;
        res = a % b;
    }
    return b;
}


/*			                       ____COMPETITIVE CODING____                                                          */

//--Header Files--

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <time.h>

//--Macros--

#define N 200001
#define R 100000007
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

//--Structures--

//--Comparator Functions--

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

//--Function Declarations--

// void qsort(array name, size of array, size of each element, comp);
// int* bsearch(address of search element, array name, size of array, size of each element, comp);
int rmdup(int [], int); // int rmDup(array, size of array);
int gcd(int, int); // int gcd(first number, second number);

//--Useful Variables--

int i = 0, j = 0, k = 0, flag = 1, count = 0, temp, pos = 0, test_case, mx = 0, mn = INT_MAX;
long long sum = 0, product = 1;

int main()
{
	//clock_t tStart = clock();
	int a, b, diff;
	scanf("%d %d", &a, &b);
	diff = abs(a - b);
	mn = MIN(a, b);
	mx = MAX(a, b);
	if(mn == mx)
	{
		printf("0\n");
		return 0;
	}
	if(mn % diff == 0)
	{
		printf("0\n");
		return 0;
	}
	if(mn < diff)
	{
		for(i = mn; i <= diff / 2; i++)
		{
			if(diff % i == 0)
			{
				flag = 0;
				break;
			}
		}
		if(!flag)
		{
			printf("%d\n", i - mn);
			return 0;
		}
		else
		{
			printf("%d\n", diff - mn);
			return 0;
		}
	}
	else
	{
		printf("%d\n", diff - mn % diff);
		return 0;
	}

	//printf("%lf seconds.\n", (clock() - tStart)/CLOCKS_PER_SEC);
	return 0;
}

int rmdup(int a[], int n)
{
	if(n == 0 || n == 1)
		return n;
	int j = 0;
	for(i = 0; i < n - 1; i++)
	{
		if(a[i] != a[i+1])
		{
			a[j++] = a[i];
		}
	}
	a[j++] = a[n-1];
	return j;
}

int gcd(int x, int y)
{
	if(y == 0)
	{
		return x;
	}
	else
	{
		return gcd(y, x % y);
	}
}


#include <stdio.h>

int main() {
	int a, b, c, x;
	long long k, k_, min, ab;

	scanf("%d%d", &a, &b);
	if (a == b) {
		printf("0\n");
		return 0;
	}
	if (a > b)
		c = a, a = b, b = c;
	min = (long long) a * b, k_ = 0;
	for (c = 1; c * c <= b - a; c++)
		if ((b - a) % c == 0) {
			x = c;
			k = (x - a % x) % x;
			ab = (a + k) * (b + k) / x;
			if (min > ab || (min == ab && k_ > k))
				min = ab, k_ = k;
			x = (b - a) / c;
			k = (x - a % x) % x;
			ab = (a + k) * (b + k) / x;
			if (min > ab || (min == ab && k_ > k))
				min = ab, k_ = k;
		}
	printf("%lld\n", k_);
	return 0;
}


/*			                       ____COMPETITIVE CODING____                                                          */

//--Header Files--

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <time.h>

//--Macros--

#define N 200001
#define R 100000007
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

//--Structures--

//--Comparator Functions--

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

//--Function Declarations--

// void qsort(array name, size of array, size of each element, comp);
// int* bsearch(address of search element, array name, size of array, size of each element, comp);
int rmdup(int [], int); // int rmDup(array, size of array);
int gcd(int, int); // int gcd(first number, second number);

//--Useful Variables--

int i = 0, j = 0, k = 0, flag = 1, count = 0, temp, pos = 0, test_case, mx = 0, mn = INT_MAX;
long long sum = 0, product = 1;

int main()
{
	//clock_t tStart = clock();
	int a, b, diff;
	scanf("%d %d", &a, &b);
	diff = abs(a - b);
	mn = MIN(a, b);
	mx = MAX(a, b);

	if(mn % diff == 0)
	{
		printf("0\n");
		return 0;
	}
	if(mn < diff)
	{
		for(i = mn; i <= diff / 2; i++)
		{
			if(diff % i == 0)
			{
				flag = 0;
				break;
			}
		}
		if(!flag)
		{
			printf("%d\n", i - mn);
			return 0;
		}
		else
		{
			printf("%d\n", diff - mn);
			return 0;
		}
	}
	else
	{
		printf("%d\n", diff - mn % diff);
		return 0;
	}

	//printf("%lf seconds.\n", (clock() - tStart)/CLOCKS_PER_SEC);
	return 0;
}

int rmdup(int a[], int n)
{
	if(n == 0 || n == 1)
		return n;
	int j = 0;
	for(i = 0; i < n - 1; i++)
	{
		if(a[i] != a[i+1])
		{
			a[j++] = a[i];
		}
	}
	a[j++] = a[n-1];
	return j;
}

int gcd(int x, int y)
{
	if(y == 0)
	{
		return x;
	}
	else
	{
		return gcd(y, x % y);
	}
}


#include <stdio.h>
#define lli long long int
int main(void){
        lli a,b;
        scanf("%lld %lld",&a,&b);
        if(a == b){
                printf("0\n");
                return 0;
        }
        if(a > b){
                int ch = a;
                a = b;
                b = ch;
        }
        lli q = b - a;
        lli j = a/q;
        if(q*j < a)
                j++;
        q *=j;
        int za = a-1;
        while(q%(++za) != 0);
        lli k = za - a;
        printf("%lld\n",k);
        return 0;
}


#include <stdio.h>

#define MD	998244353

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

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

int main() {
	int n, i, x, y, z;

	scanf("%d", &n);
	x = 1, y = 0, z = 1;
	for (i = 0; i < n; i++)
		z = x, x = (y + z) % MD, y = z;
	printf("%lld\n", z * power(2, MD - 1 - n) % MD);
	return 0;
}


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

#define M 998244353

long long add(long long a, long long b) { return (a + b + M) % M; }
long long mul(long long a, long long b) { return ((a % M) * (b % M)) % M; }
long long pw(long long a, long long r)
{
       if(r == 0) return 1;
       long long b = pw(a, r/2) % M, c = (r&1)?a:1;
       return mul(mul(b,b),c);
}

long long mat[210210],sum[210210];

void fill()
{
    int x;
    sum[0] = sum[1] = sum[2] = 1;
    for(x = 3; x <= 200000; x++)
       sum[x] = add(sum[x-1],sum[x-2]);
}

int main()
{
     int x,y,z,i,j,k,a,b,c,n,m,t;
     scanf("%d",&n);
     memset(mat, -1, sizeof(mat));
     memset(sum, 0, sizeof(sum));

     fill();

     printf("%lld\n",mul( sum[n], pw(pw(2,n), M-2) ));
     return 0;
}


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

int main(int argc, char *argv[])
{
	int xa, ya , za, xb , yb , zb ;
	double distance ;

	scanf("%d",&xa);
	scanf("%d",&ya);
	scanf("%d",&za);
	scanf("%d",&xb);
	scanf("%d",&yb);
	scanf("%d",&zb);

	distance = sqrt((xb-xa)*(xb-xa)+(yb-ya)*(yb-ya)+(zb-za)*(zb-za));

	if(za==1&&zb==1){
		printf("YES");
	}
	else if(za!=zb&&xa==xb || za!=zb&&ya==yb){
		printf("YES");
	}
	else if(za==0&&zb==0&&distance>1.4){
		printf("NO");
	}
	else if(distance>1.5){
		printf("NO");
	}
	else{
		printf("YES");
	}

	return 0;
}


#include <stdio.h>

int main(){
   int flyes[2][3];
   int i,diffs=0;
   for(i = 0; i<3; i++)
      scanf("%d",&flyes[0][i]);
   for(i = 0; i<3; i++)
      scanf("%d",&flyes[1][i]);
   for(i = 0; i<3; i++){
      if(flyes[0][i]!=flyes[1][i])
	 diffs++;
   }
   if(diffs==1)
      printf("YES");
   else
      printf("NO");

   return 0;
}


#include <stdio.h>
#include <Windows.h>

char arr[1001][1001];
char my[1001][1001];
int stamp(int a, int b) {
	int i, j, c = 1;
	//memo

	//stamp!
	for (i = -1; i <= 1; i++) {
		for (j = -1; j <= 1; j++) {
			if (i == 0 && j == 0)
				continue;
			else if (arr[a + i][b + j] == '#')
				continue;
			else
				c = 0;
		}
	}
	if (c) {
		for (i = -1; i <= 1; i++) {
			for (j = -1; j <= 1; j++) {
				if (i == 0 && j == 0)
					continue;
				else
					my[a + i][b + j] = '#';
			}
		}
	}
}
int main() {
	int n, m;
	int i, j;
	char tmp;
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%s", arr[i]);
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			my[i][j] = '.';
		}
	}

	for (i = 1; i < n - 1; i++) {
		for (j = 1; j < m - 1; j++) {
			stamp(i, j);
		}
	}
	i = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (my[i][j] != arr[i][j]) {
				printf("NO");
				system("pause");
				return 0;
			}
		}
	}
	printf("YES");
	system("pause");
	return 0;
}


#include <stdio.h>
#include <Windows.h>

char arr[1001][1001];
char my[1001][1001];
int stamp(int a, int b) {
	int i, j, c = 1;
	//memo

	//stamp!
	for (i = -1; i <= 1; i++) {
		for (j = -1; j <= 1; j++) {
			if (i == 0 && j == 0)
				continue;
			else if (arr[a + i][b + j] == '#')
				continue;
			else
				c = 0;
		}
	}

	for (i = -1; i <= 1; i++) {
		for (j = -1; j <= 1; j++) {
			if (i == 0 && j == 0)
				continue;
			else
				my[a + i][b + j] = '#';
		}
	}
}
int main() {
	int n, m;
	int i, j;
	char tmp;
	scanf("%d%d", &n, &m);
	for (i = 0; i < n; i++) {
		scanf("%s", arr[i]);
	}
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			my[i][j] = '.';
		}
	}

	for (i = 1; i < n - 1; i++) {
		for (j = 1; j < m - 1; j++) {
			stamp(i, j);
		}
	}
	i = 0;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (my[i][j] != arr[i][j]) {
				printf("NO");
				system("pause");
				return 0;
			}
		}
	}
	printf("YES");
	system("pause");
	return 0;
}


#include<stdio.h>
#define ULL unsigned long long
ULL p[16]={2,3,5,7,11,13,17,29,23,29,31,37,41,43,47,53},ans=~0ULL,n;
void dfs(ULL depth,ULL temp,ULL num,ULL up)
{
    if(num>n||depth>15)return;
    if(num==n&&ans>temp)
    {
        ans=temp;
        return;
    }
    for(int i=1;i<=up;i++)
    {
        if(temp/p[depth]>ans)break;
        dfs(depth+1,temp*=p[depth],num*(i+1),i);
    }
}

int main()
{
    scanf("%llu",&n);
    dfs(0,1,1,64);
    printf("%llu",ans);
    return 0;
}


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

typedef __int64 LL;
LL p[11052];
LL prime[30] = { 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53 };
void getartprime(LL cur, int cnt, int limit, int k) {//cur：当前枚举到的数,cnt：该数的因数个数,limit：因数个数的上限；2^t1*3^t2*5^t3……t1>=t2>=t3……,第k大的素数
	if (cur>((LL)1 << 60) || cnt>1000) return;

	//if (cnt == 4) cout << cur << endl;

	if (p[cnt] != 0 && p[cnt]>cur)//当前的因数个数已经记录过且当时记录的数比当前枚举到的数要大，则替换此因数个数下的枚举到的数
		p[cnt] = cur;
	if (p[cnt] == 0)//此因数个数的数还没有出现过，则记录
		p[cnt] = cur;
	LL temp = cur;
	for (int i = 1; i <= limit; i++) {		//枚举数
		temp = temp*prime[k];
		if (temp>((LL)1 << 60)) return;
		getartprime(temp, cnt*(i + 1), i, k + 1);
	}
}
int main() {
	int n;
	memset(p, 0, sizeof(p));
	getartprime(1, 1, 1000, 0);
	/*for (int i = 1; i <= 75; i++) {
		if (p[i * 2 - 1] != 0 && p[i * 2] != 0)
			p[i] = min(p[i * 2 - 1], p[i * 2]);
		else if (p[i * 2] != 0)
			p[i] = p[i * 2];
		else
			p[i] = p[i * 2 - 1];
	}*/

	while (scanf("%d", &n), n)
		printf("%I64d\n", p[n]);
	return 0;
}


#include <stdio.h>
#define INF ~0ULL
#define ULL unsigned long long
using namespace std;
ULL p[16] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53};
ULL n, ans;
void dfs(ULL depth, ULL temp, ULL num, ULL up)
{
    if (num == n && temp < ans) ans = temp;
    if (num >= n || depth == 16) return;
    for (int i = 1; i <= up; ++i)
    {
        if (temp * p[depth] >= ans) return;
        else dfs(depth + 1, temp = temp * p[depth], num * (i + 1), i);
    }
}
int main()
{
    while (scanf("%llu", &n) != EOF)
    {
        ans = INF;
        dfs(0, 1, 1, 64);
        printf("%llu\n", ans);
    }
}


#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);
}

void multiply(int *aa, int *bb, int n) {
	static int aa_[N_], bb_[N_];
	int n_, l_, i;

	l_ = 0;
	while (1 << l_ < n + n - 1)
		l_++;
	n_ = 1 << l_;
	for (i = 0; i < n_; i++) {
		aa_[i] = i < n ? aa[i] : 0;
		bb_[i] = i < n ? bb[i] : 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);
	for (i = 0; i < n; i++)
		aa[i] = (long long) aa_[i] * vv_[l_] % MD;
}

void inv(int *aa, int *bb, int n) {
	static int aa_[N_], bb_[N_];
	int m, n_, l_, i;

	if (n == 1) {
		bb[0] = 1;
		return;
	}
	m = (n + 1) / 2;
	inv(aa, bb, m);
	l_ = 0;
	while (1 << l_ < n * 2)
		l_++;
	n_ = 1 << l_;
	for (i = 0; i < n_; i++) {
		aa_[i] = i < n ? aa[i] : 0;
		bb_[i] = i < m ? bb[i] : 0;
	}
	ntt(aa_, l_, 0), ntt(bb_, l_, 0);
	for (i = 0; i < n_; i++)
		aa_[i] = bb_[i] * (MD + 2 - (long long) aa_[i] * bb_[i] % MD) % MD;
	ntt(aa_, l_, 1);
	for (i = 0; i < n; i++)
		bb[i] = (long long) aa_[i] * vv_[l_] % MD;
}

void log_(int *aa, int *bb, int n) {
	static int pp[N + 1], qq[N + 1];
	int i;

	for (i = 0; i < n; i++)
		pp[i] = i + 1 == n ? 0 : (long long) aa[i + 1] * (i + 1) % MD;
	inv(aa, qq, n);
	multiply(pp, qq, n);
	for (i = 0; i < n; i++)
		bb[i] = i == 0 ? 0 : (long long) pp[i - 1] * vv[i] % MD;
}

void exp_(int *aa, int *bb, int n) {
	static int aa_[N + 1], bb_[N + 1], cc_[N + 1];
	int m, i;

	if (n == 1) {
		bb[0] = 1;
		return;
	}
	m = (n + 1) / 2;
	exp_(aa, bb, m);
	for (i = 0; i < n; i++)
		bb_[i] = i < m ? bb[i] : 0;
	log_(bb_, cc_, n);
	for (i = 0; i < n; i++)
		aa_[i] = (aa[i] - cc_[i] + MD) % MD;
	aa_[0] = (aa_[0] + 1) % MD;
	multiply(aa_, bb_, n);
	for (i = 0; i < n; i++)
		bb[i] = aa_[i];
}

int bell[N + 1];

void compute_bell() {
	static int aa[N + 1];
	int i;

	for (i = 1; i <= N; i++)
		aa[i] = gg[i];
	exp_(aa, bell, N + 1);
	for (i = 0; i <= N; i++)
		bell[i] = (long long) bell[i] * ff[i] % MD;
}

int sum(int n, int k) {
	static int aa[N + 1], bb[N + 1];
	int i, ans;

	if (k > n)
		return (bell[n] - 1 + MD) % MD;
	for (i = 0; i <= k; i++)
		aa[i] = power(i, n) * gg[i] % MD;
	for (i = 0; i <= k; i++)
		bb[i] = (long long) (i % 2 == 0 ? 1 : MD - 1) * gg[i] % MD;
	multiply(aa, bb, k + 1);
	ans = MD - 1;
	for (i = 0; i <= k; i++)
		ans = (ans + aa[i]) % 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;
	}
	compute_bell();
	ans = 0;
	for (d = 1; d < n; d++)
		if (mobius[d])
			ans = (ans + sum((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>

#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>

#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;

	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) {
		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>

#define N	200000
#define L_	21	/* 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;

	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) {
		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>

long long int fun(long long int a, long long int b)
{
    long long int ans=0;
    while(a%b==0)
    {
        a/=b;
        ans++;
    }
    return ans;
}

int main()
{
    long long int a, b, c, d, i, ans=0;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
    for(i=3; i>1; i--)
    {
        while(fun(a, i)+fun(b, i) != fun(c, i)+fun(d, i))
        {
            ans++;
            if(fun(a, i)+fun(b, i) > fun(c, i)+fun(d, i))
            {
                if(fun(a, i))
                    a/=i*(i-1);
                else
                    b/=i*(i-1);
            }
            else
            {
                if(fun(c, i))
                    c/=i*(i-1);
                else
                    d/=i*(i-1);
            }
        }
    }
    if(a*b!=c*d)
        printf("-1\n");
    else
        printf("%lld\n%lld %lld\n%lld %lld\n", ans, a, b, c, d);
    return 0;
}


#include <stdio.h>
#include <string.h>
typedef long long ll;
char s[4][105] = {"What are you doing at the end of the world? Are you busy? Will you save us?", "What are you doing while sending \"", "\"? Are you busy? Will you send \"", "\"?"};
ll lens[4], lenf[100005], zuida;

char DFS(ll n, ll k)
{
    if(n == 0) return k < lenf[0] ? s[0][k] : '.';
    if(lenf[n] <= k) return '.';
    if(k < lens[1]) return s[1][k];
    if(k < lens[1] + lenf[n - 1])
        return DFS(n - 1, k - lens[1]);
    if(k < lens[1] + lenf[n - 1] + lens[2])
        return s[2][k - lens[1] - lenf[n - 1]];
    if(k < lens[1] + lenf[n - 1] + lens[2] + lenf[n - 1])
        return DFS(n - 1, k - lens[1] - lenf[n - 1] - lens[2]);
    return s[3][k - lens[1] - lenf[n - 1] - lens[2] - lenf[n - 1]];
}

int main()
{
    ll q, n, k, i;
    scanf("%I64d", &q);
    for(i = 0; i < 4; ++i)
        lens[i] = strlen(s[i]);
    lenf[0] = lens[0];
    for(zuida = 1; lenf[zuida - 1] <= 2e18; ++zuida)
        lenf[zuida] = 2 * lenf[zuida - 1] + lens[1] + lens[2] + lens[3];
    for(i = zuida; i <= 100002; ++i)
        lenf[i] = lenf[i - 1];
    while(q--)
    {
        scanf("%I64d%I64d", &n, &k);
        --k;
        printf("%c", DFS(n, k));
    }
    puts("");
    return 0;
}


#include <stdio.h>
#include <string.h>
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <assert.h>

const char* f0  = "What are you doing at the end of the world? Are you busy? Will you save us?";
const char* fi1 = "What are you doing while sending \"";
const char* fi2 = "\"? Are you busy? Will you send \"";
const char* fi3 = "\"?";
static const int f0len = 75, fi1len = 34, fi2len = 32, fi3len = 2;

#define MAX_N 100000
static int64_t _flen[MAX_N+1] = {};

#define MAX_K 1000000000000000000LL

static char dfs(int64_t N, int64_t* K) {
    if(N == 0) {                                // leaf of the tree
        if(*K >= f0len) {
            *K -= f0len; return '.';
        } else {
            char c = f0[*K]; *K = 0; return c;
        }
    }
    if(*K < fi1len) {                           // inside fi1
        char c = fi1[*K]; *K = 0; return c;
    }
    *K -= fi1len;

    if(_flen[N-1] == 0) {                       // need memoize
        const int64_t kk = *K;
        const char c = dfs(N-1, K);             // dfs into the first child
        if(c == '.') _flen[N-1] = kk - *K;
        else         return c;
    } else {
        if(*K < _flen[N-1]) {                   // dfs into the first child
            char c = dfs(N-1, K); *K = 0; return c;
        } else *K -= _flen[N-1];                // just skip this child
    }
    assert(_flen[N-1]);

    if(*K < fi2len) {                           // inside fi2
        char c = fi2[*K]; *K = 0; return c;
    }
    *K -= fi2len;

    assert(_flen[N-1]);
    if(*K < _flen[N-1]) {                       // dfs into the second child
        char c = dfs(N-1, K); *K = 0; return c;
    } else *K -= _flen[N-1];                    // just skip this child

    if(*K < fi3len) {                           // inside fi3
        char c = fi3[*K]; *K = 0; return c;
    }
    *K -= fi3len;
    return '.';
}

int main() {
    _flen[0] = f0len;
    int Q; scanf("%d\n", &Q); while(Q--) {
        int64_t N,K; scanf(" %"PRId64 " %"PRId64 "\n", &N, &K);
        --K; printf("%c", dfs(N,&K));
    }
    printf("\n");
    return 0;
}


#include<stdio.h>
#include<string.h>
char s1[200]="What are you doing at the end of the world? Are you busy? Will you save us?";
char s2[100]="What are you doing while sending \"";
char s3[100]="\"? Are you busy? Will you send \"";
char s4[7]="\"?";
long long int arr[100012];
char letter(long long int n,long long int k){
long long int z,i;
long long int l1=strlen(s1),l2=strlen(s2),l3=strlen(s3),l4=strlen(s4);
if(k>arr[n]){
return '.';
}
if(n==0){
return s1[k-1];}
if(k<=34){
return s2[k-1];
}
k-=l2;
if(k<=arr[n-1]){
return letter(n-1,k);}
k=k-arr[n-1];
if(k<=l3){
return s3[k-1];}
k=k-l3;
if(k<=arr[n-1]){
return letter(n-1,k);}
k=k-arr[n-1];
if(k<=2){
return s4[k-1];
}
}
int main(){
long long int q,n,k,i;
char z[11];
scanf("%lld",&q);
arr[0]=75;
arr[1]=218;
for(i=2;i<=55;i++){
arr[i]=arr[i-1]*2+68;
}
for(i=55;i<100010;i++){
arr[i]=arr[53];
}
for(i=1;i<=q;i++){
scanf("%lld",&n);
scanf("%lld",&k);
z[i]=letter(n,k);
}
for(i=1;i<=q;i++){
printf("%c",z[i]);
}
printf("\n");
return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
char* tmps1="What are you doing while sending \"";
char* tmps2="\"? Are you busy? Will you send \"";
char* tmps3="\"?";
char* f0="What are you doing at the end of the world? Are you busy? Will you save us?";
long long pow2[54]={1};
char calc(int n,long long k)
{
	if (n==0) return f0[k-1];
	if (k<=strlen(tmps1)) return tmps1[k-1];
	k-=strlen(tmps1);
	long long len1=pow2[n-1]*143-68;
	if (k<=len1) return calc(n-1,k);
	k-=len1;
	if (k<=strlen(tmps2)) return tmps2[k-1];
	k-=strlen(tmps2);
	if (k<=len1) return calc(n-1,k);
	k-=len1;
	return tmps3[k-1];
}
int main()
{
	int i;
	for (i=1;i<=53;i++) pow2[i]=2*pow2[i-1];
	int q;
	scanf("%d",&q);
	while (q--)
	{
		int n; long long k;
		scanf("%d%I64d",&n,&k);
		if (n<=53&&k>pow2[n]*143-68)
		{
			printf("."); continue;
		}
		if (k<34*n)
		{
			 printf("%c",tmps1[(k-1)%34]);
			 continue;
		}
		if (n>53)
		{
			printf("%c",calc(53,k-34*(n-53)));
		}
		else printf("%c",calc(n,k));
	}

	return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>
char* tmps1="What are you doing while sending \"";
char* tmps2="\"? Are you busy? Will you send \"";
char* tmps3="\"?";
char* f0="What are you doing at the end of the world? Are you busy? Will you save us?";
long long pow2[54]={1};
char calc(int n,long long k)
{
	if (n==0) return f0[k-1];
	if (k<=strlen(tmps1)) return tmps1[k-1];
	k-=strlen(tmps1);
	long long len1=pow2[n-1]*143-68;
	if (k<=len1) return calc(n-1,k);
	k-=len1;
	if (k<=strlen(tmps2)) return tmps2[k-1];
	k-=strlen(tmps2);
	if (k<=len1) return calc(n-1,k);
	k-=len1;
	return tmps3[k-1];
}
int main()
{
	int i;
	for (i=1;i<=53;i++) pow2[i]=2*pow2[i-1];
	int q;
	scanf("%d",&q);
	while (q--)
	{
		int n; long long k;
		scanf("%d%I64d",&n,&k);
		if (n<=53&&k>pow2[n]*143-68)
		{
			printf("."); continue;
		}
		if (k<34*n)
		{
			 printf("%c",tmps1[(k-1)%34]);
			 continue;
		}
		if (n>53)
		{
			printf("%c",calc(53,k-34*(n-53)));
		}
		else printf("%c",calc(n,k))
	}
	printf("\n")
	return 0;
}


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

long long int Input;
long long int A, B, i, x, y, Ans;
long long int Test;

void DFS(long long int Number, int UsedA, int UsedB){
    Number *= 10;
    if (Number+A<=Input){
        UsedA = 1;
        if (UsedA) if (UsedB) if (Number+A>=10) Ans++;
        if (A || Number+A) DFS(Number+A, UsedA, UsedB);
    }
    if (A!=B) if (Number+B<=Input){
        UsedB = 1;
        if (UsedA) if (UsedB) if (Number+B>=10) Ans++;
        if (B || Number+B) DFS(Number+B, UsedA, UsedB);
    }
}

int main(){
    while(~scanf("%I64d", &Input)){
        Ans = 0;
        for (A=1; A<=Input; A++){
            if (A>9) break;
            Ans++;
        }

        for (A=0; A<10; A++) for (B=A+1; B<10; B++) if (A+B){
            DFS(0, 0, 0);
        }

        printf("%I64d\n", Ans);
    }

    return 0;
}


#include<stdio.h>
#include<string.h>
int main(void)
{
    int n,i,j,k,t,count1,count2,flag,num[100],a;
    while(scanf("%d",&n)!=EOF)
    {
        count2=0;
        for(k=102;k<=n;k++)
        {
            memset(num,0,sizeof(num));
            count1=0;
            flag=1;
            t=k;
            while(t!=0)
            {
                a=t%10;
                num[a]++;
                t=t/10;
            }
            for(j=0;j<=9;j++)
            {
                if(num[j]!=0)
                    count1++;
                if(count1==3)
                    flag=0;
            }
            if(flag==0)
            {
                count2++;
            }
        }
        printf("%d\n",n-count2);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
struct node{
	int s,e,d,id;
}a[105];
int b[105];
void sort(struct node a[],int m){
	struct node temp;
	int i,j;
	for(i=1;i < m;i++){
	   for(j = 1;j < m-i;j++){
	   	if(a[j].e > a[j+1].e){
	   		temp = a[j];
	   		a[j] = a[j+1];
	   		a[j+1] = temp;
			}
		}
	}
}
int main(){
	int n,m;
	int i,j,t;
	int flag = 0;
	while(scanf("%d%d",&n,&m) != EOF){
		memset(b,0,sizeof(b));
		for(i = 1;i <= m;i++){
			scanf("%d%d%d",&a[i].s,&a[i].e,&a[i].d);
			a[i].id = i;
			b[a[i].e] = m + 1;
		}
		sort(a,m);
		for(i = 1;i <= m;i++){
			int count = 0;
			for(j = a[i].s;j < a[i].e;j++){
				if(b[j] == 0){
					b[j] = a[i].id;
					count++;
				}
				if(count == a[i].d) break;
			}
			if(count != a[i].d){
				flag = 1;
				break;
			}
		}
		if(flag == 1){
			printf("-1\n");
		}
		else{
			for(j = 1;j <= n-1;j++){
				printf("%d ",b[j]);
			}
			printf("%d\n",b[j]);
		}

	}
	return 0;
}


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

struct exam{
	int a;
	int b;
	int c;
};

struct exam x[100];
int s[100],day[100]={0};

int compare(const void *a,const void *b){
	return x[*(int *)a].b-x[*(int *)b].b;
}

int main(void){
	int n,m,i,j;

	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d %d %d",&x[i].a,&x[i].b,&x[i].c);
		s[i]=i;
		day[x[i].b-1]=i+1;
	}

	qsort(s,m,sizeof(int),compare);

	for(i=0;i<n;i++){
		if(day[i]!=0){
			if(x[day[i]-1].c>0){
				printf("-1\n");
				return 0;
			}
			else{
				day[i]=m+1;
			}
		}
		else{
			for(j=0;j<m;j++){
				if(i+1>=x[s[j]].a&&x[s[j]].c>0){
					x[s[j]].c--;
					day[i]=s[j]+1;
					break;
				}
			}
		}
	}

	for(i=0;i<n-1;i++){
		printf("%d ",day[i]);
	}
	printf("%d\n",day[n-1]);

	return 0;
}


#include <stdio.h>
#include <stdlib.h>
struct ex {int s; int d; int c; int n;};
int cm (const void *A, const void *B){
	return	((struct ex *)A)->d - ((struct ex *)B)->d;
	}
int main (){
int i, j, n, m;
int const MAX = 100;
int ans[100] = {0};
struct ex a[MAX];

scanf("%d %d",&n, &m);
for (i=0;i < m;i++){
	scanf("%d %d %d", &a[i].s, &a[i].d, &a[i].c);
	a[i].n = i + 1;
	ans[a[i].d - 1] = m + 1;
	}

qsort(a,m,sizeof a[0], cm);
j = 0;
for (i=0;i<n;i++){
	if(ans[i] == m + 1){
		j++;
		continue;
		}
	int k;
	for(k = j; k < m ; k++){
		if (a[k].s <= i + 1 && a[k].c > 0 ){
			ans[i] = a[k].n;
			a[k].c--;
			break;
			}
		}

	}
//check
j = 0;
for (i=0;i<m;i++)
	j += a[i].c;

if (j > 0)
//if(0)
	printf("-1");
else
	for (i = 0; i<n; i++)
		printf("%i ",ans[i]);
printf("\n");
return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
int g[105][105],n,m,i,j,f[105],ff,ans[105];
struct u
{
	int a,b,c,d;
}k[105];

int cmp(const void *x,const void *y)
{
	return ((struct u*)x)->b-((struct u*)y)->b;
}

int main()
{
	memset(g,0,sizeof(g));
	memset(f,0,sizeof(f));
	scanf("%d %d",&n,&m);
	for (i=1;i<=m;i++)
	{
		scanf("%d %d %d",&k[i].a,&k[i].b,&k[i].d);
		k[i].c=i;
	}
	qsort(&k[1],m,sizeof(struct u),cmp);
	for (i=1;i<=m;i++)
	{
		for (j=k[i].a;j<k[i].b;j++) g[i][j]=1;
		f[k[i].b]=i;
	}
	for (i=1;i<=n;i++)
	{
		if (f[i])
		{
			if (k[f[i]].d<=0) ans[i]=m+1;
			else
			{
				printf("-1\n");
				return 0;
			}
			continue;
		}
		for (j=1,ff=0;j<=m;j++)
		if (g[j][i]&&k[j].d)
		{
			ans[i]=k[j].c;
			k[j].d--;
			ff=1;
			break;
		}
		if (!ff) ans[i]=0;
	}
	for (i=1;i<=n;i++) printf("%d ",ans[i]);
	return 0;
}


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

typedef struct ExamData_m
{
	int start;
	int needed;
	int day;
	int index;
} ExamData;

void Swap(ExamData *a, ExamData *b)
{
	ExamData aux = *a;
	*a = *b;
	*b = aux;
}

int Partition(ExamData exams[], int left, int right)
{
	int mid = left + (right - left) / 2;
	Swap(exams + left, exams + mid);

	int pivot = exams[left].start;
	int i = left + 1;
	int j = right;

	while (i <= j) {
		while (i <= j && exams[i].start <= pivot) {
			i += 1;
		}
		while (i <= j && exams[j].start > pivot) {
			j -= 1;
		}
		if (i <= j) {
			Swap(exams + i, exams + j);
			i += 1;
			j -= 1;
		}
	}

	Swap(exams + left, exams + i - 1);
	return i - 1;
}

void Sort(ExamData exams[], int left, int right)
{
	if (left >= right) {
		return;
	}

	int index = Partition(exams, left, right);
	Sort(exams, left, index - 1);
	Sort(exams, index + 1, right);
}

typedef ExamData HeapNode;

int Father(int node) { return node / 2; }
int LeftSon(int node) { return node * 2 + 1; }
int RightSon(int node) { return node * 2 + 2; }

void Percolate(HeapNode heap[], int node)
{
	if (node <= 0) {
		return;
	}

	int father = Father(node);
	if (heap[node].day < heap[father].day) {
		Swap(heap + node, heap + father);
		Percolate(heap, father);
	}
}

void Sift(HeapNode heap[], int size, int node)
{
	int left = LeftSon(node);
	int right = RightSon(node);

	if (left >= size) {
		return;
	}

	int best = left;
	if (right < size && heap[right].day < heap[left].day) {
		best = right;
	}

	if (heap[best].day < heap[node].day) {
		Swap(heap + best, heap + node);
		Sift(heap, size, best);
	}
}

void AddExam(HeapNode heap[], int *size, ExamData exam)
{
	heap[*size] = exam;
	*size += 1;
	Percolate(heap, *size - 1);
}

void Study(HeapNode heap[], int *size)
{
	heap[0].needed -= 1;
	if (heap[0].needed <= 0) {
		*size -= 1;
		Swap(heap, heap + *size);
		Sift(heap, *size, 0);
	}
}

#define MAX_DAYS 100

int days[MAX_DAYS];
int needed[MAX_DAYS];
ExamData exams[MAX_DAYS];

HeapNode choser[MAX_DAYS];
int choser_size = 0;

int main()
{
	int ndays, nexams;
	scanf("%d%d", &ndays, &nexams);

	int i;
	for (i = 0; i < ndays; ++i) {
		days[i] = -1;
	}

	for (i = 0; i < nexams; ++i) {
		scanf("%d%d%d", &exams[i].start, &exams[i].day, &exams[i].needed);
		exams[i].index = i;

		exams[i].start -= 1;
		exams[i].day -= 1;
		days[exams[i].day] = i;
		needed[i] = exams[i].needed;
	}

	Sort(exams, 0, nexams - 1);

	int valid = 1;
	int exam_ind = 0;

	for (i = 0; i < ndays && valid; ++i) {
		while (exam_ind < nexams && exams[exam_ind].start == i) {
			AddExam(choser, &choser_size, exams[exam_ind]);
			exam_ind += 1;
		}

		if (days[i] != -1) {
			if (needed[days[i]] > 0) {
				valid = 0;
			}
			days[i] = nexams;
			continue;
		}

		if (choser_size > 0) {
			int ind = choser[0].index;
			days[i] = ind;
			needed[ind] -= 1;
			Study(choser, &choser_size);
		}
	}

	if (!valid) {
		printf("-1\n");
		return 0;
	}

	for (i = 0; i < ndays; ++i) {
		printf("%d ", days[i] + 1);
	}
	printf("\n");

	return 0;
}


#include <stdio.h>

const long long mod = 1e9 + 9;

int main() {
  long long n, m, i;
  scanf("%I64d %I64d", &n, &m);
  long long now = 1;
  for(i = 1; i <= m; i++) {
    now *= 2;
    now %= mod;
  }
  long long ans = 1;
  for(i = 1; i <= n; i++) {
    now--;
    if(now < 0) now += mod;
    ans *= now;
    ans %= mod;
  }
  printf("%d\n", (int) ans);
  return 0;
}


#include <stdio.h>

#define MOD 1000000009

long long int power(int, int, int);

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);

	long long int p = power(2, m, MOD);
	long long int sol = 1;
	int i;
	for (i=1;i<=n;i++)
	{
		long long int t = p - i;
		if (t<0) t+=MOD;
		sol *= t;
		sol %= MOD;
	}

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

long long int power(int base, int exp, int mod)
{
	if (!exp) return 1;
	long long int t = power(base, exp / 2, mod);
	long long int tt = (exp & 1)?base:1;
	return (((t * t) % mod) * tt) % mod;
}


#include <stdio.h>

typedef long long ll;

const ll mod = 1000000009;

void solve(int n, int m)
{
    ll ans, s, i;
    s = 1;
    for (i = 0; i < m; i ++)
    {
        s = (s << 1) % mod;
    }
    ans = 1;
    for (i = 0; i < n; i ++)
    {
        s --;
        if (s == 0)
        {
            printf("0\n");
            return;
        }
        ans = (ans * s) % mod;
    }
    printf("%I64d\n", ans);
}

int main()
{
    int n, m;
    while (scanf("%d%d", &n, &m) == 2)
    {
        solve(n, m);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define SORT(a,n) qsort(a,n,sizeof(int),intcmp)
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define fill(a,v)                   memset(a, v, sizeof(a))
int intcmp(const void *f,const void *s)
{
   return (*(int *)f -*(int *)s);
}
int gcd(int a,int b){ return ((b==0)?a:gcd(b,a%b));}

#define MAX
#define MODBY 1000000009

typedef long long int lld;
typedef long double Lf;

int main()
{
   int i,j,n,m;
   scanf("%d",&n);
   scanf("%d",&m);
   lld a=1;
   for(i=0;i<m;++i)
      a=(a*2)%MODBY;
   lld ans=1;
   for(i=1;i<=n;++i)
      ans=(ans*(a-i+MODBY))%MODBY;
   printf("%d\n",(int)ans);

   return 0;
}


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

int main() {
	static char str[64];
	int l, i, res;

	scanf("%s", str);
	l = strlen(str);
	res = 0;
	for (i = 0; i < l; i++) {
		int check1 = str[i] > '@' && str[i] < '[';
		int check2 = str[i] > '`' && str[i] < '{';
		int c = tolower(str[i]);

		if (isalpha(c)) {
			c -= ('a' - 1);
			res += check1 * c - check2 * c;
		}
	}
	printf("%d\n", res);
	return 0;
}


#include<stdio.h>
long long n,n1,sum,a[20],value;

long long findMinOnes(long long n,int i)
{
	int count = 0;
	long long value1,value2;
	if(n<0)
		n *=-1;
	if(i==1)
		return n;
	if(n==1)
		return 1;
		while(n>a[i])
		{
			n-= a[i];
			count+=i;
		}
		value1 = count + findMinOnes(n,i-1);
		n-= a[i];
		count+=i;
		value2 = count + findMinOnes(n,i-1);
		if(value1 < value2)
			return value1;
		else
			return value2;
}
int main()
{
	int k=1,i=0,count;
	int mul = 10;
	scanf("%I64d",&n);
	n1=n;
	while(n!=0)
	{
		n=n/10;
		i++;
	}
	a[k]=1;
	for(k=2;k<=i+1;k++)
	{
		a[k]=a[k-1]+mul;
		mul*=10;
	}
	n=n1;
	printf("%I64d",findMinOnes(n,i+1));
	return 0;
}


#include<stdio.h>
int main()
{
	long long n,i,k=0,min=0,temp=0;
	long long a[1000000] = {0};
	scanf("%I64d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%I64d",&a[i]);
		k+= a[i];
	}
	k = k/n;
	for(i=0;i<n;i++)
	{
		if(temp < 0)
		min+= temp * -1;
		else
		min+= temp;
		temp+=a[i]-k;

	}
	printf("%I64d",min);
	return 0;
}


#include <stdio.h>
#define lli long long int
lli n,i,j,u,k,l,x,y,d,s,t;
lli gg(lli x){int u=0;  while(x){u++;x/=10;} return u;}
lli ggg(lli n)
{
    while(n/10)n/=10;
    return n;
}
lli g(lli u)
{
    lli a=1;
    while(--u)a=10*a+1;
    return a;
}
lli f(lli n);
lli fff(lli n)
{
    lli u=gg(n);
    if(u==1) return 2+(11-n);
    if(ggg(n)<6) return 10000;
    return u+1+f(g(u+1)-n);
}
lli ff(lli n)
{
    lli u=gg(n);
    if(u==1)return n;
    return ggg(n)*u+(f(n-ggg(n)*g(u)));
}
lli f(lli n)
{
    if(!n)return 0;
    if(n<0)n*=-1;
    lli x,y,u=gg(n);
    x=ff(n);
    y=fff(n);
    return (x>y ? y : x);
}
int main()
{
    scanf("%lld",&n);
    x=n;
    while(x){u++;x/=10;}
    printf("%lld",f(n));
    return 0;
}


#include<stdio.h>
#include<string.h>
#define abs(x) (( (x>0) ? x : -x ))
int n,y,k,i,t,x,d,u;
char a[100];
int main()
{
	scanf("%s",a);
	u=strlen(a);
	n=u;
	for(i=0;i<u;i++)
		a[i]-='0';
	t+=a[0]*n;
	n--;
	k=a[0];
	for(i=1;i<u;i++)
	{
		x=a[i]-k;
		if(x<0)
			x*=-1;
		k=a[i];
		t+=n*x;
		n--;
	}
	printf("%d",t);
	return 0;
}


#include<stdio.h>
long long n,n1,sum,a[20],value;

long long findMinOnes(long long n,int i)
{
	int count = 0;
	long long value1,value2;
	if(n<0)
		n *=-1;
	if(i==1)
		return n;
	if(n==1)
		return 1;
		while(n>a[i])
		{
			n-= a[i];
			count+=i;
		}
		value1 = count + findMinOnes(n,i-1);
		n-= a[i];
		count+=i;
		value2 = count + findMinOnes(n,i-1);
		if(value1 < value2)
			return value1;
		else
			return value2;
}
void main()
{
	int k=1,i=0,count;
	int mul = 10;
	scanf("%I64d",&n);
	n1=n;
	while(n!=0)
	{
		n=n/10;
		i++;
	}
	a[k]=1;
	for(k=2;k<=i+1;k++)
	{
		a[k]=a[k-1]+mul;
		mul*=10;
	}
	n=n1;
	printf("%I64d",findMinOnes(n,i+1));
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int f(long long int i,long long int tmp,long long int m);
long long int min1(long long int a,long long int b);
int main()
{
    long long int m,n,s,i,p,tmp,kase=1,min;
    scanf("%lld%lld",&m,&n);
    s=m+n;
    for(i=1;i<=sqrt(s);i++)
    {
        if(s%i!=0)
            continue;
        tmp=s/i;
        m=min1(m,n);
        if(f(i,tmp,m))
        {
            p=2*(i+tmp);
            if(kase)
            {
                min=p;
                kase=0;
            }
            else
                min=min<p?min:p;

        }
    }
    printf("%lld",min);
    return 0;
}
int f(long long int i,long long int tmp,long long int m)
{
    int j;
    for(j=1;j<=sqrt(m);j++)
    {
        if(m%j!=0)
            continue;
        if(j<=i&&m/j<=tmp||j<=tmp&&m/j<=i)
            return 1;
    }
    return 0;
}
long long int min1(long long int a,long long int b)
{
    return a<b?a:b;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int f(long long int i,long long int tmp,long long int m);
long long int min1(long long int a,long long int b);
int main()
{
    long long int m,n,s,i,p,tmp,kase=1,min=99999999999;
    scanf("%lld%lld",&m,&n);
    s=m+n;
    for(i=sqrt(s);i>=1;i--)
    {
        if(s%i!=0)
            continue;
        tmp=s/i;

        if(f(i,tmp,n))
        {
            p=2*(i+tmp);
            min=p<min?p:min;
            break;
        }

    }
    for(i=sqrt(s);i>=1;i--)
    {

        if(f(i,tmp,m))
        {
            p=2*(i+tmp);
            min=p<min?p:min;
            break;
    }
    printf("%lld",min);
    return 0;
}
}
int f(long long int i,long long int tmp,long long int m)
{
    int j;
    for(j=sqrt(m);j>=1;j--)
    {
        if(m%j!=0)
            continue;
        if(j<=i&&m/j<=tmp||j<=tmp&&m/j<=i)
            return 1;
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int f(long long int i,long long int tmp,long long int m);
long long int min1(long long int a,long long int b);
int main()
{
    long long int m,n,s,i,p,tmp,kase=1,min;
    scanf("%lld%lld",&m,&n);
    s=m+n;
    for(i=sqrt(s);i>=1;i--)
    {
        if(s%i!=0)
            continue;
        tmp=s/i;

        if(f(i,tmp,n))
        {
            p=2*(i+tmp);
            break;
        }

    }
    for(i=sqrt(s);i>=1;i--)
    {

        if(f(i,tmp,m))
        {
            p=2*(i+tmp);
            break;
    }
    printf("%lld",p);
    return 0;
}
}
int f(long long int i,long long int tmp,long long int m)
{
    int j;
    for(j=sqrt(m);j>=1;j--)
    {
        if(m%j!=0)
            continue;
        if(j<=i&&m/j<=tmp||j<=tmp&&m/j<=i)
            return 1;
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int f(long long int i,long long int tmp,long long int m);
long long int min1(long long int a,long long int b);
int main()
{
    long long int m,n,s,i,p,tmp,kase=1,min;
    scanf("%lld%lld",&m,&n);
    s=m+n;
    for(i=1;i<=s;i++)
    {
        if(s%i!=0)
            continue;
        tmp=s/i;
        m=min1(m,n);
        if(f(i,tmp,m))
        {
            p=2*(i+tmp);
            if(kase)
            {
                min=p;
                kase=0;
            }
            else
                min=min<p?min:p;

        }
    }
    printf("%lld",min);
    return 0;
}
int f(long long int i,long long int tmp,long long int m)
{
    int j;
    for(j=1;j<=m;j++)
    {
        if(m%j!=0)
            continue;
        if(j<=i&&m/j<=tmp||j<=tmp&&m/j<=i)
            return 1;
    }
    return 0;
}
long long int min1(long long int a,long long int b)
{
    return a<b?a:b;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
long long int f(long long int i,long long int tmp,long long int m);
int min1(int a,int b);
int main()
{
    long long int m,n,s,i,p,tmp,kase=1,min;
    scanf("%lld%lld",&m,&n);
    s=m+n;
    for(i=1;i<=sqrt(s);i++)
    {
        if(s%i!=0)
            continue;
        tmp=s/i;
        m=min1(m,n);
        if(f(i,tmp,m))
        {
            p=2*(i+tmp);
            if(kase)
            {
                min=p;
                kase=0;
            }
            else
                min=min<p?min:p;

        }
    }
    printf("%lld",min);
    return 0;
}
long long int f(long long int i,long long int tmp,long long int m)
{
    int j;
    for(j=1;j<=sqrt(m);j++)
    {
        if(m%j!=0)
            continue;
        if(j<=i&&m/j<=tmp)
            return 1;
    }
    return 0;
}
int min1(int a,int b)
{
    return a<b?a:b;
}


#include <stdio.h>
long long int n, k, M, D;

long long int max(long long int a, long long int b)
{
	if (a > b)
		return a;
	return b;
}

int main()
{
	scanf("%I64d %I64d %I64d %I64d", &n, &k, &M, &D);
	long long int ans = M;
	for (long long int i = D; i >= 2; i--)
	{
		if (n/D < k)
			continue;
		long long int beg = 1, end = M;

		while (beg <= end)
		{
			long long int mid = (beg+end)/2;
			long long int num = n/mid;
			//printf("%d, %d, %d\n", i, mid, num);
			if (num < k*(i-1)+1)
			{
				end = mid-1;
			}
			else if (i == D && num >= k*i+1)
			{
				beg = mid+1;
			}
			else if (num >= k*(i-1)+1)
			{
				ans = max(ans, (i)*mid);
				beg = mid+1;
			}
			else
			{
				beg = mid+1;
				ans = max(ans, (i)*mid);
			}
		}
	}

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


#include<stdio.h>

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


#include<stdio.h>

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


#include<stdio.h>

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


#include <stdio.h>
long long int n, k, M, D;

long long int max(long long int a, long long int b)
{
	if (a > b)
		return a;
	return b;
}

int main()
{
	scanf("%I64d %I64d %I64d %I64d", &n, &k, &M, &D);
	long long int ans = 0;
	for (long long int i = D; i >= 1; i--)
	{
		if (n/D < k)
			continue;
		long long int beg = n/(k*(i-1)), end = M;
		while (beg <= end)
		{
			long long int mid = (beg+end)/2;
			long long int num = n/mid;
			//printf("%d, %d, %d\n", i, mid, num);
			if (num < k*(i-1)+1)
			{
				end = mid-1;
			}
			else if (i == D && num >= k*i+1)
			{
				beg = mid+1;
			}
			else if (num >= k*(i-1)+1)
			{
				ans = max(ans, (i)*mid);
				beg = mid+1;
			}
			else
			{
				beg = mid+1;
				ans = max(ans, (i)*mid);
			}
		}
	}

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


#include <stdio.h>

int n,t,c;

void dfs(int y1,int y2,int x,int l) {
	// printf("%d %d %d %d\n",y1,y2,x,l);
	if (x==2&&y1<y2) return;
	if (l>t) return;
	if (x==n) {
		if (y1<y2&&t==l) c++;
		return;
	}
	int y;
	for (y=1;y<5;y++)
		if (y!=y1)
			dfs(y,y1,x+1,l+(y1>y2&&y1>y));
}

int main() {
	scanf("%d %d\n",&n,&t);
	dfs(0,-1,0,0);
	printf("%d\n",c);
	return 0;
}


#include<stdio.h>
int main()
{
	int i,j,k,l,m,flag=0,n,x1,y1,x2,y2;
	long int sum=0,ans=0,temp;
	scanf("%d",&n);
	int a[n];
	int xmin[n],ymin[n],xmax[n],ymax[n];
	int minx,miny,maxx,maxy;
	for(i=0;i<n;i++)
	{
		scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
		a[i]=(x2-x1)*(y2-y1);
		xmin[i]=x1;
		xmax[i]=x2;
		ymin[i]=y1;
		ymax[i]=y2;
	}
	for(i=0;i<n;i++)
	{
		sum =a[i];
		minx=xmin[i];
		miny=ymin[i];
		maxx=xmax[i];
		maxy=ymax[i];
		if(maxx-minx==maxy-miny)
		{
			temp=(maxx-minx)*(maxy-miny);
			if(temp == sum)
			{
				flag=1;
			}
		}
		for(j=i+1;j<n;j++)
		{
			sum += a[j];
			if(xmin[j]<minx)	minx=xmin[j];
			if(ymin[j]<miny)	miny=ymin[j];
			if(xmax[j]>maxx)	maxx=xmax[j];
			if(ymax[j]>maxy)	maxy=ymax[j];
			if(maxx-minx==maxy-miny)
			{
				temp=(maxx-minx)*(maxy-miny);
				if(temp == sum)
				{
					flag=1;
				}
			}
			for(k=j+1;k<n;k++)
			{
				sum += a[k];
				if(xmin[k]<minx)	minx=xmin[k];
				if(ymin[k]<miny)	miny=ymin[k];
				if(xmax[k]>maxx)	maxx=xmax[k];
				if(ymax[k]>maxy)	maxy=ymax[k];
				if(maxx-minx==maxy-miny)
				{
					temp=(maxx-minx)*(maxy-miny);
					if(temp == sum)
					{
						flag=1;
					}
				}
				for(l=k+1;l<n;l++)
				{
					sum += a[l];
					if(xmin[l]<minx)	minx=xmin[l];
					if(ymin[l]<miny)	miny=ymin[l];
					if(xmax[l]>maxx)	maxx=xmax[l];
					if(ymax[l]>maxy)	maxy=ymax[l];
					if(maxx-minx==maxy-miny)
					{
						temp=(maxx-minx)*(maxy-miny);
						if(temp == sum)
						{
							flag=1;
						}
					}
					for(m=l+1;m<n;m++)
					{
						sum += a[m];
						if(xmin[m]<minx)	minx=xmin[m];
						if(ymin[m]<miny)	miny=ymin[m];
						if(xmax[m]>maxx)	maxx=xmax[m];
						if(ymax[m]>maxy)	maxy=ymax[m];
						if(maxx-minx==maxy-miny)
						{
							temp=(maxx-minx)*(maxy-miny);
							if(temp == sum)
							{
								flag=1;
							}
						}
					}
				}
			}
		}
	}
	if(flag==1)	printf("YES\n");
	else printf("NO\n");
	return 0;
}


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

#define K	22
#define N	25000000

int pp[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
	31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
	73, 79 };

char bad[N + 1];

int solve1(int n, int p) {
	int a, b, cnt;

	if (n < p)
		return n == 0 ? 0 : 1;
	memset(bad, 0, (n + 1) * sizeof *bad);
	cnt = n;
	for (a = 2; a < p; a++) {
		if (bad[a])
			continue;
		for (b = a; b <= n; b += a)
			if (!bad[b]) {
				bad[b] = 1;
				cnt--;
			}
	}
	return cnt;
}

int solve2(int n, int k) {
	long long ans;
	int b, i;

	ans = 0;
	for (b = 0; b < 1 << k; b++) {
		int m = n, parity = 0;

		for (i = 0; i < k; i++)
			if ((b & 1 << i) != 0) {
				int p = pp[i];

				m /= p;
				parity ^= 1;
			}
		ans += parity == 0 ? m : -m;
	}
	return ans;
}

int prime(int p) {
	int a;

	for (a = 2; a <= p / a; a++)
		if (p % a == 0)
			return 0;
	return 1;
}

int main() {
	int a, b, p, ans, i;

	scanf("%d%d%d", &a, &b, &p);
	if (!prime(p)) {
		printf("0\n");
		return 0;
	}
	i = 0;
	while (i < K && pp[i] < p)
		i++;
	if (i == K)
		ans = solve1(b / p, p) - solve1((a - 1) / p, p);
	else
		ans = solve2(b / p, i) - solve2((a - 1) / p, i);
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#define gmax(a,b) ((a)>(b)?(a):(b))
long tot1,tot2,total=0,z[5000005]={0},hash[20000005]={0},last[20000005]={0},ans1,ans2;
long work1(long count,long k)
{
	long o=count/k,tot=0,sum=0,i,j;
	for(i=2;i<=o;i++)
	{
		if(hash[i]==0)
		{
			z[++tot]=i;
			last[i]=i;
		}
		for(j=1;j<=tot && z[j]*i<=o;j++)
		{
			hash[z[j]*i]=1;
			last[z[j]*i]=z[j];
			if(i%z[j]==0)
				break;
		}
	}
	for(i=2;i<=o;i++)
		if(last[i]>=k)
			sum++;
	if(count>=k)
		sum++;
	return sum;
}
void dfs(long k,long p,long long u)
{
	if(u>gmax(tot1,tot2))
		return ;
	if(k<=total)
	{
		dfs(k+1,p,u);
		dfs(k+1,p+1,u*z[k]);
	}
	else if(p)
	{
		if(p%2)
		{
			ans1-=tot1/u;
			ans2-=tot2/u;
		}
		else
		{
			ans1+=tot1/u;
			ans2+=tot2/u;
		}
	}
}
long check(long k)
{
	long i;
	for(i=2;i<=sqrt(k);i++)
		if(k%i==0)
			return 0;
	return 1;
}
int main()
{
	long k,i,A,B,j;
//	freopen("d.in","r",stdin);
//	freopen("d.out","w",stdout);
	scanf("%ld %ld %ld\n",&A,&B,&k);
	if(check(k)==0)
	{
		printf("0\n");
		return 0;
	}
	if(k>=100)
		printf("%ld\n",work1(B,k)-work1(A-1,k));
	else
	{
		for(i=2;i<k;i++)
		{
			if(hash[i]==0)
			{
				z[++total]=i;
				last[i]=i;
			}
			for(j=1;j<=total && z[j]*i<k;j++)
			{
				hash[z[j]*i]=1;
				if(i%z[j]==0)
					break;
			}
		}
		tot1=B/k; tot2=(A-1)/k;
		ans1=B/k; ans2=(A-1)/k;
		dfs(1,0,1);
		printf("%ld\n",ans1-ans2);
	}

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define ll long long
#define N 31807

int getPrime(int n,int p[]){int i,j,n2=n/2;rep(i,n2)p[i]=1;for(i=3;i*i<n;i+=2)if(p[i>>1])for(j=(i*i)>>1;j<n2;j+=i)p[j]=0;j=1;p[0]=2;REP(i,1,n2)if(p[i])p[j++]=i*2+1;return j;}
int ps, p[N];

ll res, pp;
int a,b,n;

void solve(ll now, int st, int num){
  int i,j,k;
  ll send, add;

  add = b / now - (a-1) / now;
  if(num%2) add *= -1;
  res += add;

  REP(i,st,pp){
    send = now * p[i];
    if(send > b) break;
    solve(send, i+1, num+1);
  }
}

int is_prime(int n){
  int i;
  rep(i,ps){
    if(in[i]*in[i] > n) break;
    if(n%in[i]==0) return 0;
  }
  return 1;
}

int main(){
  int i,j,k,l,m;

  ps = getPrime(N,p);

  while(scanf("%d%d%d",&a,&b,&n)==3){
    rep(i,ps) if(n==p[i]) break;
    if(i==ps){
      if(a<=n && n<=b && is_prime(n)) puts("1"); else puts("0");
      continue;
    }

    pp = i;
    res = 0;
    solve(n,0,0);

    printf("%d\n",(int)res);
  }

  return 0;
}


#include <stdio.h>
#define gmax(a,b) ((a)>(b)?(a):(b))
long tot1,tot2,total=0,z[5000005]={0},hash[20000005]={0},last[20000005]={0},ans1,ans2;
long work1(long count,long k)
{
	long o=count/k,tot=0,sum=0,i,j;
	for(i=2;i<=o;i++)
	{
		if(hash[i]==0)
		{
			z[++tot]=i;
			last[i]=i;
		}
		for(j=1;j<=tot && z[j]*i<=o;j++)
		{
			hash[z[j]*i]=1;
			last[z[j]*i]=z[j];
			if(i%z[j]==0)
				break;
		}
	}
	for(i=2;i<=o;i++)
		if(last[i]>=k)
			sum++;
	return sum;
}
void dfs(long k,long p,long long u)
{
	if(u>gmax(tot1,tot2))
		return ;
	if(k<=total)
	{
		dfs(k+1,p,u);
		dfs(k+1,p+1,u*z[k]);
	}
	else if(p)
	{
		if(p%2)
		{
			ans1-=tot1/u;
			ans2-=tot2/u;
		}
		else
		{
			ans1+=tot1/u;
			ans2+=tot2/u;
		}
	}
}
int main()
{
	long k,i,A,B,j;
//	freopen("d.in","r",stdin);
//	freopen("d.out","w",stdout);
	scanf("%ld %ld %ld\n",&A,&B,&k);
	if(check(k)==0)
		printf("0\n");
	if(k>=100)
		printf("%ld\n",work1(B,k)-work1(A-1,k));
	else
	{
		for(i=2;i<k;i++)
		{
			if(hash[i]==0)
			{
				z[++total]=i;
				last[i]=i;
			}
			for(j=1;j<=total && z[j]*i<k;j++)
			{
				hash[z[j]*i]=1;
				if(i%z[j]==0)
					break;
			}
		}
		tot1=B/k; tot2=(A-1)/k;
		ans1=B/k; ans2=(A-1)/k;
		dfs(1,0,1);
		printf("%ld\n",ans1-ans2);
	}

	return 0;
}


#include <stdio.h>
#include <time.h>
#include <stdlib.h>
char a[20][11],b[20][11];
int n;
int check()
{
    int k=0;
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            if (a[n+i][j]!=b[i][j])
            {
                k=1;
                break;
            }
        }
    }
    if (k==0)
    {
        printf("YES");
        return 10;
    }
    else
        return 0;
}
void ud()
{
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            b[n-i-1][j]=a[i][j];
        }
    }
}
void lr()
{
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            b[i][n-j-1]=a[i][j];
        }
    }
}
void rot()
{
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            b[n-j-1][i]=a[i][j];
        }
    }
}
void match()
{
    for (int i=0; i<n; i++)
    {
        for (int j=0; j<n; j++)
        {
            a[i][j]=b[i][j];
        }
    }
}
int main()
{
    scanf("%d",&n);
    for (int i=0; i<n*2; i++)
    {
        scanf("%s",a[i]);
    }
    for (int i=0; i<4; i++)
    {
        rot();
        match();
        if (check()==10)
            return 0;
        ud();
        match();
        if (check()==10)
            return 0;
        lr();
        match();
        if (check()==10)
            return 0;
        ud();
        match();
        if (check()==10)
            return 0;
        lr();
        match();
        if (check()==10)
            return 0;
    }
    printf("NO");
    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>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <stdbool.h>
int n,m,i,j,ans[505],k,z,ff,f[55],l,s;
struct u
{
	int a,b;
}a[55],b[55];

void swap(int *x,int *y)
{
	int t;

	t=*x;
	*x=*y;
	*y=t;
}

int main()
{
	scanf("%d %d",&n,&m);
	for (i=1;i<=n;i++)
	{
		scanf("%d %d",&a[i].a,&a[i].b);
		if (a[i].a>a[i].b) swap(&a[i].a,&a[i].b);
	}
	for (i=1;i<=m;i++)
	{
		scanf("%d %d",&b[i].a,&b[i].b);
		if (b[i].a>b[i].b) swap(&b[i].a,&b[i].b);
	}
	for (i=1,k=0,ff=0;i<=n;i++)
	{
		for (j=1,z=0;j<=m;j++)
		{
			memset(f,0,sizeof(f));
			f[a[i].a]++;
			f[a[i].b]++;
			f[b[j].a]++;
			f[b[j].b]++;
			for (l=1,s=0;l<=9;l++)
			if (f[l]) s++;
			if (s==3)
			{
				for (l=1,s=0;l<=9;l++)
				if (f[l]==2)
				{
					ans[++k]=l;
					z++;
					break;
				}
			}
		}
		if (z>1) ff=1;
	}
	if (k==1)
	{
		printf("%d\n",ans[1]);
		exit(0);
	}
	else if (!ff)
	{
		puts("0");
		exit(0);
	}
	else puts("-1");
	return 0;
}


#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <stdbool.h>
int n,m,i,j,ans[505],k,z,ff,f[55],l,s;
struct u
{
	int a,b;
}a[55],b[55];

void swap(int *x,int *y)
{
	int t;

	t=*x;
	*x=*y;
	*y=t;
}

int main()
{
	scanf("%d %d",&n,&m);
	for (i=1;i<=n;i++)
	{
		scanf("%d %d",&a[i].a,&a[i].b);
		if (a[i].a>a[i].b) swap(&a[i].a,&a[i].b);
	}
	for (i=1;i<=m;i++)
	{
		scanf("%d %d",&b[i].a,&b[i].b);
		if (b[i].a>b[i].b) swap(&b[i].a,&b[i].b);
	}
	for (i=1,k=0,ff=0;i<=n;i++)
	{
		for (j=1,z=0;j<=m;j++)
		{
			memset(f,0,sizeof(f));
			f[a[i].a]++;
			f[a[i].b]++;
			f[b[j].a]++;
			f[b[j].b]++;
			for (l=1,s=0;l<=9;l++)
			if (f[l]) s++;
			if (s==3)
			{
				for (l=1,s=0;l<=9;l++)
				if (f[l]==2)
				{
					ans[++k]=l;
					z++;
					break;
				}
			}
		}
		if (z>1) ff=1;
	}
	if (k==1)
	{
		printf("%d\n",ans[1]);
		exit(0);
	}
	else if (!ff&&k)
	{
		puts("0");
		exit(0);
	}
	else puts("-1");
	return 0;
}


#define _USE_MATH_DEFINES
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#include <float.h>
#include <limits.h>
#include <malloc.h>
#include <memory.h>
#include <complex.h>
#include <errno.h>
#include <time.h>
int n,m,i,j,k,min,ans[25][25],f[25],d[25],s;
struct u
{
	int a,b;
}a[5][25];

void dfs(int x,int y,int z)
{
	int i;

	if (x<=0) return;
	for (i=1;i<=y;i++)
	if (!f[i])
	{
		f[i]=1;
		memset(d,0,sizeof(d));
		d[a[z^1][x].a]++;
		d[a[z^1][x].b]++;
		d[a[z][i].a]++;
		d[a[z][i].b]++;
		for (j=1,s=0;j<=9;j++)
		if (d[j])
		{
			s++;
			if (d[j]==2) k=j;
		}
		if (s==3)
		{
			ans[x][k]++;
		}
		dfs(x-1,y,z);
		f[i]=0;
	}
}

int main()
{
	scanf("%d %d",&n,&m);
	for (i=1;i<=n;i++) scanf("%d %d",&a[0][i].a,&a[0][i].b);
	for (i=1;i<=m;i++) scanf("%d %d",&a[1][i].a,&a[1][i].b);
	min=n<m ? n : m;
	memset(f,0,sizeof(f));
	memset(ans,0,sizeof(ans));
	if (m<n) dfs(m,n,0); else dfs(n,m,1);
	memset(d,0,sizeof(d));
	for (i=1;i<=min;i++)
	{
		for (j=1,s=0;j<=9;j++)
		if (ans[i][j])
		{
			d[j]++;
			s++;
		}
		ans[i][0]=s;
	}

	for (i=1,s=0;i<=9;i++)
	if (d[i])
	{
		s++;
		k=i;
	}
	if (s==0) puts("-1");
	else if (s==1) printf("%d\n",k);
	else
	{
		for (i=1,s=0;i<=min;i++)
		if (ans[i][0]>1)
		{
			s=1;
			break;
		}
		if (s) puts("-1"); else puts("0");
	}
	return 0;
}


#include <stdio.h>
#include <algorithm>
using namespace std;
long long ans=0;
long long hei(long long a,long long b,long long c,long long m)
{
     long long cnt=min(a-b-c,m);
     if (cnt<0) return 0; else return (cnt+1)*(cnt+2)/2;
}
int main()
{
     long long a,b,c,l;
     cin>>a>>b>>c>>l;
     ans+=(l+3)*(l+2)*(l+1)/6;
     for (long long i=0;i<=l;i++) ans-=hei(a+i,b,c,l-i)+hei(b+i,a,c,l-i)+hei(c+i,a,b,l-i);
     cout<<ans;
     return 0;
}


#include <iostream>
#include <algorithm>
using namespace std;
long long ans=0;
long long hei(long long a,long long b,long long c,long long m)
{
     long long cnt=min(a-b-c,m);
     if (cnt<0) return 0; else return (cnt+1)*(cnt+2)/2;
}
int main()
{
     long long a,b,c,l;
     cin>>a>>b>>c>>l;
     ans+=(l+3)*(l+2)*(l+1)/6;
     for (long long i=0;i<=l;i++) ans-=hei(a+i,b,c,l-i)+hei(b+i,a,c,l-i)+hei(c+i,a,b,l-i);
     cout<<ans;
     return 0;
}