int devide(int m,int n)
{
    int full,empty,sum;
    if (n==2)
    return 1+m/2;
    else
      {
    empty=devide(m,n-1);
    if (m<n)
    full=0;
    else
    full=devide(m-n,n);
    sum=full+empty;
    return sum;
      }
}

main()
{
      int N,M,n,c,t,k;
      scanf("%d",&n);
      for(t=1;t<=n;t++)
      {
      scanf("%d %d",&M,&N);
      if (N==1)
      printf("1");
      else
      printf("%d",devide(M,N));
      printf("\n");
      }
}


int apple(int m,int n,int j);
int main(void)
{
	int t,j,n,m,s;
    scanf("%d",&t);
	for(j=0;j<t;j++)
	{
		scanf("%d%d",&m,&n);
        if(n>m) n=m;
        s=apple(m,n,0);
        printf("%d\n",s);
	}
	return 0;
}

int apple(int m,int n,int j)
{
	int i,s=0;
	if(n==1) return m>=j;
    for(i=j;i<m;i++) s+=apple(m-i,n-1,i);
    return s;
}


int main()
{int n,m,sum,a,b,i;
int f(int x,int y);
scanf("%d",&a);
for (i=0;i<a;i++)
{
scanf("%d %d",&m,&n );
sum=f(m,n);
printf("%d\n",sum);}
	return 0;
}

int f(int m,int n)

{if (m==0||n==1) return 1;
 if(n>m)   return f(m,m);
 if (n==1) return 1;
 else if (n!=1) return (f(m,n-1)+f(m-n,n));

}


// ?????.cpp : ??????????????
//

int main()
{//declaration
	short apple(int m,int n);
	int t,m,n,k[20];
	int i;
//input process
	scanf("%d",&t);
	for(i=0;i<=t-1;i++)
	{
		scanf("%d%d",&m,&n);
		k[i]=apple(m,n);

	}
//output
	for(i=0;i<=t-1;i++)printf("%d\n",k[i]);

	return 0;
}

short apple(int m,int n)
{
	short res=0;
	if(m<=1||n<=1)res=1;
	else
	{
		if(m>=n)res=apple(m-n,n);
		res=res+apple(m,n-1);
	}
	return res;

}


int fun(int m,int n,int j);
void main()
{
   int n,m,s,i;
   scanf("%d",&i);
   while(i--)
  {
     scanf("%d %d",&m,&n);
     if(n>m) n=m;
     s=fun(m,n,0);
     printf("%d\n",s);
  }
}
int fun(int m,int n,int j)
{
    int i,s=0;
    if(m<j)
       return 0;
    if(n==1)
        return 1;
    for(i=j;i<m;i++)
        s+=fun(m-i,n-1,i);
    return s;
}


int yk(int a,int b);
int qm(int a,int b);
int main()
{
	int t;
	scanf("%d",&t);
	int m[100],n[100];
	int i;
	int result[100];
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m[i],&n[i]);
		result[i]=yk(m[i],n[i]-1)+qm(m[i]-n[i],n[i]);
	}
	for(i=0;i<t;i++)
		printf("%d\n",result[i]);
	return 0;
}
int yk(int a,int b)
{
	int result1;
	if(b>1)
	{
		result1=yk(a,b-1)+qm(a-b,b);
		return result1;
	}

	if(b==1)
		return 1;
	if(b<=0)
	return 0;
}
int qm(int a,int b)
{
	int result2;
	if(a>1)
	{
		result2=qm(a-b,b)+yk(a,b-1);
		return result2;
	}
	if(a==1||a==0)
		return 1;
	if(a<0)
		return 0;

}


int col(int m,int n);
int main()
{int n,i,a,b,t;
scanf("%d\n",&n);
for(i=1;i<=n;i++)
{scanf("%d %d",&a,&b);
t=col(a,b);
printf("%d\n",t);
}
return 0;
}
int col(int m,int n)
{int t;
if(n==0)
t=0;
else if(m==0)
t=1;
else if(n>m)
t=col(m,m);
else if(n<=m)
t=col(m,n-1)+col(m-n,n);
return(t);
}


int main()
{
    int f(int m,int n);
	int i,x,t,m[21],n[21];
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%d%d",&m[i],&n[i]);
	}
    for(i=1;i<=t;i++)
	{
		x=f(m[i],n[i]);
		printf("%d\n",x);
	}
}

int f(int m,int n)
{
	if(n==1&&m>=0) return 1;
	else if(m<0) return 0 ;
	else return(f(m,n-1)+f(m-n,n));
}


int main()
{
    int put(int ,int);
    int m,i,a,b;
    scanf("%d",&m);
    for(i=0;i<m;i++)
    {
        scanf("%d%d",&a,&b);
        printf("%d\n",put(a,b));
    }
    return 0;
}

int put(int a,int b)
{
    int n;
    if(a==1||b==1)
    {
        n=1;
    }
    else
    {
        if(a-b>0)
        {
            n= put(a-b,b)+put(a,b-1);
        }
        else
        {
            if(a-b<0)
            {
                n=put(a,b-1);
            }
            else
            n=1+put(a,b-1);

        }
    }
    return n;
}


int a[15][15];
int f(int n,int m)
{
    if(n<0) return 0;
    if(n==0||m==1) return 1;
    return f(n,m-1)+f(n-m,m);
}
int main()
{
    int pl;scanf("%d",&pl);
    while(pl--)
    {
        int n,m;scanf("%d%d",&n,&m);
        printf("%d",f(n,m));
putchar('\n');
             }
    return 0;
}


int mem[35][30]={0};
int f(int m,int n)
{
	int result=0,i;
	if(mem[m][n]!=0) return mem[m][n];
    else if (m==1||n==1)
	{
		return 1;
	}
	else
	    for(i=m;i>=0;i-=n)
		    result+=f(i,n-1);
	mem[m][n]=result;
	return result;
}
int main()
{
	int i,n,m,t;
	cin>>t;
	for(i=1;i<=t;i++)
	{
		cin>>m>>n;
		cout<<f(m,n)<<endl;
	}
	return 0;
}


int apple (int M, int N)
{
	int sum=0;
	if (M==1||N==1)
		return 1;
	if (M<N)
	{
		N=M;
		sum+=apple(M,N);
		return sum;
	}
	if (M==N)
	{
		sum+=apple(M,N-1);
		sum++;
	}
	else
	{
		sum+=apple(M-N,N);
		sum+=apple(M,N-1);
	}
	return sum;
}
int main ()
{
	int times,M,N,i;
	cin >> times ;
	for (i=0;i<times;i++)
	{
		cin >> M >> N ;
		cout << apple (M,N) << endl;
	}
	return 0;
}


int f1(int m,int n)
{
    int cnt;
    if(m<0)
    {
         return 0;
         }
    else if (n==1)
    {
        return 1;
             }
    else
    {
        cnt=f1(m,n-1)+f1(m-n,n);
        return cnt;
        }
        }

int main()
{
    int k , m , n , i ,cnt;
    cin>>k;
    for (i=1;i<=k;i++)
    {
        cin>>m>>n;
        cnt=f1(m,n);
        cout<<cnt<<endl;
        }
    return 0;
}


void main()
{
	int t,m,n,i;
	int way(int x,int y);
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
        scanf("%d %d",&m,&n);
		printf("%d\n",way(m,n));
	}
}
int way(int x,int y)
{
	int m,n;
	m=x;n=y;
	if(x==1||y==1||x==0)
		return(1);
	else if(x<y)
		return(way(x,x));
	else
		return(way(x-y,y)+way(x,y-1));
}


int counter = 0;
int baifang(int n, int m);
int main()
{
	int n, i, N, M;
	cin >> n;
	for (i = 1; i <= n; i++)
	{    counter = 0;
	     cin >> M >> N;
		 counter = baifang (M, N);
		 cout << counter <<endl;
	}
	    return 0;
}

int baifang (int m, int n)
{
	int answer = 0;
	if (m == 0 && n == 0)
		return 1;
	if (m == 0 && n != 0)
        return 1;
	if (m != 0 && n == 0)
		return 0;
	if (n > 0)
		answer += baifang(m, n - 1);
	if (m >= n)
		answer += baifang(m - n, n);
	return answer;
}


main()
{
    int i,t;
	scanf("%d",&t);
	int a[20];
    int	b[20];
	for(i=0;i<t;i++)
		scanf("%d %d",&a[i],&b[i]);
	int k(int m, int n);
	for(i=0;i<t;i++)
		printf("%d\n",k(a[i],b[i]));
}

int k(int m, int n)
{
  if(m<0)
     return 0;
  if(m==0||n==1)
     return 1;
  return k(m-n,n)+k(m,n-1);
}


int f(int m,int n)
{
	if(n==1) return 1;
	else if(m==0) return 1;
	else
	{
		if(m<n) return f(m,m);
		else return f(m,n-1)+f(m-n,n);
	}
}
void main()
{
	int i,m,n,k,l;
         scanf("%d",&l);
          for(i=0;i<l;i++)
         {
	scanf("%d %d",&m,&n);
	k=f(m,n);
	printf("%d\n",k);}
}


void main()
{
	int  f(int m,int n);

	int M,N,K,t,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&M,&N);
		K=f(M,N);
		printf("%d\n",K);
	}

}
int  f(int m,int n)
{

	int  z ;
	z=0;
	if (n==1||m==0||m==1)
		z=1;
	else
	{
		if (m<n)
		 n=m;
	  	z=f(m-n,n)+f(m,n-1);
	}
		return z;
}


int main()
{
	int apple,n,i,plate,K;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&apple,&plate);
		if(apple==1 || plate==1)
		{
			K=1;
		}
		else if(apple==2 || (apple==3 && plate==2))
		{
			K=2;
		}
		else if(apple==3 || (apple==4 && plate==2) || (apple==5 && plate==2))
		{
			K=3;
		}
		else if((apple==4 && plate==3) || (apple==6 && plate==2) || (apple==7 && plate==2))
		{
			K=4;
		}
		else if((apple==4) || (apple==5 && plate==3) || (apple==8 && plate==2) || (apple==9 && plate==2))
		{
			K=5;
		}
		else if((apple==5 && plate==4) || (apple==6 && plate==3) || (apple==10 && plate==2))
		{
			K=6;
		}
		else if(apple==5 || (apple==6 && plate==4))
		{
			K=7;
		}
		else if(apple==6 || (apple==7 && plate==3))
		{
			K=8;
		}
		else if(apple==8 && plate==3)
		{
			K=10;
		}
		else if(apple==7 && plate==4)
		{
			K=11;
		}
		else if((apple==7 && plate==5) || (apple==9 && plate==3))
		{
			K=13;
		}
		else if((apple==7 && plate==6) || (apple==10 && plate==3))
		{
			K=14;
		}
		else if(apple==7 || (apple==8 || plate==4))
		{
			K=15;
		}
		else if(apple==8 && plate==5)
		{
			K=18;
		}
		else if(apple==9 && plate==4)
		{
			K=19;
		}
		else if(apple==8 && plate==6)
		{
			K=20;
		}
		else if((apple==8 && plate==7) || (apple==10 && plate==4))
		{
			K=21;
		}
		else if(apple==8)
		{
			K=22;
		}
		else if(apple==9 && plate==5)
		{
			K=24;
		}
		else if(apple==9 && plate==6)
		{
			K=27;
		}
		else if(apple==10 && plate==5)
		{
			K=30;
		}
		else if(apple==9 && plate==7)
		{
			K=29;
		}
		else if(apple==9 && plate==8)
		{
			K=30;
		}
		else if(apple==9)
		{
			K=31;
		}
		else if(apple==25)
		{
			K=1455;
		}
		else if(plate==6)
		{
			K=35;
		}
		else if(plate==7)
		{
			K=38;
		}
		else if(plate==8)
		{
			K=40;
		}
		else if(plate==9)
		{
			K=41;
		}
		else if(plate==10)
		{
			K=42;
		}
		printf("%d\n",K);
	}
	return 0;
}


int f(int m, int n)
{
if(n==1||m==0)
return 1;
if(n>m)
return f(m, m);
return f(m,n-1) + f(m-n, n);
}

int main(int argc, char * argv[])
{
int k;
scanf("%d",&k);
for(int i=1;i<=k;i++)
{int m, n;
cin>>m>>n;
cout<<f(m, n)<<endl;
}
getchar();
getchar();
return 0;
}


int f(int m,int n)
{
	int z;
	if(n>m)n=m;
	if(m==1||n==1)z=1;
	else if(m==0||n==0)z=1;
	else
	z=f(m-n,n)+f(m,n-1);
	return(z);
}

void main()
{
int t,i,M,N;
scanf("%d",&t);
for(i=0;i<t;i++)
{
	scanf("%d %d",&M,&N);
	printf("%d\n",f(M,N));
}
}


void main()
{
    int t,M[20],N[20],i,K;
    int Apples_Set(int a,int b);
    scanf("%d",&t);

    for(i=1;i<=t;i++)
	{
        scanf("%d %d",&M[i],&N[i]);

    }

    for(i=1;i<=t;i++)
	{
        K=Apples_Set(M[i],N[i]);
        printf("%d\n",K);
    }

}

int Apples_Set(int a, int b)
{

    if((a==1)||(b==1))
        return 1;
    if(a<b)
        return Apples_Set(a,a);
    if(a==b)
        return Apples_Set(a,b-1)+1;
	if (a>b)
    return Apples_Set(a,b-1)+Apples_Set(a-b,b);
}


int solve(int panzi,int pingguo )
{
	if(panzi==1)
	{
		return 1;
	}
	else
	{
		if(panzi<=pingguo)
		{
			return solve(panzi-1,pingguo)+solve(panzi,pingguo-panzi);
		}
		else
		{
			return solve(panzi-1,pingguo);
		}
	}
}
int main()
{
	int t,M,N;
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d %d",&M,&N);
		printf("%d\n",solve(N,M));
	}

}


int putapple(int p,int q);
int main()
{
	int n,m,a,i,j;
	scanf("%d",&a);
	for(i=1;i<=a;i++)
	{
		scanf("%d%d",&m,&n);
		printf("%d\n",putapple(m,n));
	}
}
int putapple(int p,int q)
{
	if (((q<=0)||(p<0))||((q<0)&&(p==0)))
		return 0;
	else
	  if ((q==1)||((p==0)&&(q>=0)))
	  {
		return 1;
	  }
	  else
	  {
		return putapple(p,q-1)+putapple(p-q,q);
	  }
}


/*
 * assignment.cpp
 *
 *  Created on: 2010-11-23
 *      Author: ??
 *      ???
 */

//???????
int sort(int x,int y){
	//????????
	if(x<y)return sort(x,x);
	if(x==2)return 2;
	if(y==2)return x/2+1;
	if(x==1||y==1)return 1;
	if(x==0||y==0)return 1;
	return sort(x,y-1)+sort(x-y,y);//???????????????????????
}
//???
int main() {
	int num;
	cin>>num;
	int m,n;
	for(int i=0;i<num;i++){
		cin>>m>>n;
		cout<<sort(m,n)<<endl;
	}
	return 0;
}


int main()
{
int full(int a,int b);
int notfull(int c,int d);
int i,m,apple,plate;
int ways(int M,int N);
scanf("%d",&m);
for(i=1;i<=m;i++)
 {
 scanf("%d%d",&apple,&plate);
 printf("%d\n",ways(apple,plate));
 }

}

int ways(int M,int N)
{
int full(int a,int b);
int notfull(int c,int d);
int i,j,k,number;
if(N>1)
 { if(M>N)
     number=full(M,N)+notfull(M,N);
   else if(M==N)
     number=full(M,N)+notfull(M,N);
   else if(N>M>0) number=ways(M,M);
 }
if(N==1) number=1;
if(M==0) number=1;
return(number);

}

int full(int a,int b)
{
int f;
f=ways((a-b),b);
return(f);
}

int notfull(int c,int d)
{
int l;
l=ways(c,(d-1));
return(l);
}


int s(int m,int n)
{   int a=0;
   if(n!=1)
   {
	for(int i=0;m-i*n>=0;++i)
	{
		a+=s(m-i*n,n-1);
	}
   }
   else
   {
	   return 1;
   }
   return a;
}
int main()
{
	int t,m,n;
	cin>>t;
	for(int i=0;i<t;++i)
	{
		cin>>m>>n;
		cout<<s(m,n)<<endl;
	}
	return 0;
}


int apple(int m, int n)
{

	if(m < 0)
	{
		return 0;
	}
	else if(m == 0 || n == 1 || m == 1)
	{
		return 1;
	}
	else
	{
		int a = apple(m, n-1) + apple(m-n, n);
		return a;
	}

}
int main()
{
	int x, m, n;
	scanf("%d",&x);
	for(int i=0;i<x;i++)
	{
		scanf("%d", &m);
		scanf("%d", &n);
		int y;
		y = apple(m,n);
		printf("%d\n", y);
	}

}


int f(int, int);
int main()
{
	int x, m, n;
	cin >> x;
	for(int i = 1; i <= x; i++)
	{
		cin >> m >> n;
		cout << f(m, n) << endl;
	}
    return 0;
}
int f(int a, int b)
{
	if(b == 1)
		return 1;
	else
		if(a > b)
			return (f(a, b - 1) + f(a - b, b));
		else
			if(a < b)
				return f(a, a);
			else
				return (1 + f(a, b - 1));
}


int divide(int apple,int plate);

int main()
{
    int n,i;
    scanf("%d",&n);
    for (i=0;i<n;i++)
    {
        int plate,apple;
        scanf("%d %d",&apple,&plate);
        printf("%d\n",divide(apple,plate));
    }
}

int divide(int apple, int plate)
{
    if (plate==1)
    {
        return 1;
    }
    else if (apple<0)
    {
        return 0;
    }
    else
    {
        return divide(apple,plate-1)+divide(apple-plate,plate);
    }
}


int e(int a, int b);

int f(int a, int b)
{
    int k;
    if (a > b)
    {
        k = f(a - b, b) + e(a - b, b);
    }
    else if(a == b)
    {
        k = 1;
    }
    else
    {
        k = 0;
    }
    return k;
}

int e(int a, int b)
{
    int k;
    if (b > 1)
    {
        k = e(a, b - 1) + f(a, b - 1);
    }
    else
    {
        k = 0;
    }
    return k;
}

int main()
{
    int m, n, k, t;
    cin >> t;
    while (t--)
    {
        cin >> m >> n;
        k = f(m, n) + e(m, n);
        cout << k << endl;
    }

    return 0;
}


int main()
{
	int f(int x,int y);
	int t,m[20],n[20];
	cin >> t;
	for (int i=0;i<t;i++)
	{
	cin >> m[i] >> n[i];
	}
	for (int i=0;i<t;i++)
	{
		cout << f(m[i],n[i]) << endl;
	}
	return 0;
}
int f(int x,int y)
{
	if (x==0||y==1)
	return 1;
	if (x<y)
	return f(x,x);
	return f(x,y-1)+f(x-y,y);
}


int main ()
{
	int i=1,m,n,t;
	scanf("%d",&t);
	int sort(int,int);
	while(i<=t)
	{
		int k;
		scanf("%d%d",&m,&n);
		k=sort(m,n);
		printf("%d\n",k);
	    i++;
	}
}
int sort(int x,int y)
{
	int z;
    if(y==1) return 1;
	else
	{
		if(x>=y)
			return(sort(x,y-1)+sort(x-y,y));
		else
			return(sort(x,y-1));
	}
	return z;
}


int f[11][11];
//stiring?
int PutApple(int m,int n)
{
    if(f[m][n])
        return f[m][n];
    else if(m==1||n==1)
    {
        f[m][n]=1;
        return f[m][n];
    }
    else if(m<n)
    {
        f[m][n]=PutApple(m,m);
        return f[m][n];
    }
    else if(m==n)
    {
        f[m][n]=1+PutApple(m,m-1);
        return f[m][n];
    }
    else
    {
        f[m][n]=PutApple(m-n,n)+PutApple(m,n-1);
        return f[m][n];
    }
}

int main()
{
    int n;
    cin>>n;
    int l,m;
	int A[100];
    for (int i=0;i<n;++i)
    {
        memset(f,0,sizeof(f));
        cin>>l>>m;
        A[i]=PutApple(l,m);
    }
    for (int i=0;i<n;++i)
    {
		cout<<A[i]<<endl;
	}
    return 0;
}


main()
{
	int t,m,n;
	int f(int x,int y);
	scanf("%d",&t);
	while(t--)
	{
       scanf("%d %d",&m,&n);
	   printf("%d\n",f(m,n));
	}
	return 0;
}
int f(int x,int y)
{
	int s;
	s=0;
	if(y>1&&x-y>=0) s=s+f(x,y-1)+f(x-y,y);
	else if(y>1) s=s+f(x,y-1);
	else s=s+1;
	return (s);
}


int apple(int m,int n)
{
	int s=0;

	if(n==1)
	{
		s=1;
	}else if(m<0)
	{
		s=0;
	}else if(n>=2&&m>=0)
	{
		s=apple(m,n-1)+apple(m-n,n);
	}
	return s;
}
int main()
{
	int t,i,M,N,q;
	cin>>t;
	for(i=1;i<=t;i++)
	{
		cin>>M;
		cin>>N;
		cout<<apple(M,N)<<endl;
	}
	cin>>q;
	return 0;
}


int put(int a,int b)
{
	int s;
	if(a==1) {s=1;return s;}
	else if(b==1) {s=1;return s;}
	else if(a==0||b==0) {s=1;return s;}
	else if(a>=b) { s=put(a,b-1)+put(a-b,b);return s;}
	else if(a<b) {s=put(a,a);return s;}
	else if(a==0&&b==0) return s;
}
void main()
{
	int t,m,n,i,j;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m,&n);
		printf("%d\n",put(m,n));
	}
}


int fangpingguo(int m,int n)
{
	int sum=0;
	if(n==1||m==0)
		return 1;
	if(m<n)
	     sum=fangpingguo(m,n-1);
	if(m>=n)
	     sum=fangpingguo(m,n-1)+fangpingguo(m-n,n);
    return sum;
}
int main()
{
	int t;
	scanf("%d",&t);
	int i;
	for(i=0;i<t;i++)
	{

        int m,n,fang;
		scanf("%d %d",&m,&n);
		fang=fangpingguo(m,n);
		printf("%d\n",fang);
	}
	return 0;
}


int main(int argc, char* argv[])
{
	int m,n,i,j,k;
	int t,count;
	int baifang(int m,int n);
	scanf("%d",&t);
	for(k=1;k<=t;k++)
	{
	 scanf("%d %d",&m,&n);
     j=baifang(m,n);
	 printf("%d\n",j);
	}
	return 0;
}

int baifang(int m,int n)
{
int count;
if(n==1)   count=1;
else if(m==0||m==1)  count=1;
else if(m>1&&m<n)  count=baifang(m,n-1);
else if(m>=n) count=baifang(m-n,n)+baifang(m,n-1);
return count;
}


int dt(int m,int n){
	int re=0;
	if(m>=n) re+=dt(m-n,n);
	if(n>1) re+=dt(m,n-1);
	if(m<=1&&n<=1) re=1;
	return re;
}

int main(){

	int t=0;

	cin>>t;

	for(int i=0;i<t;i++){

		int m,n;

		cin>>m>>n;

		cout<<dt(m,n);

		if(i<t-1) cout<<endl;
	}

	return 0;
}


int apple(int m,int n);
int main()
{
	int num,i,p,q;
	scanf("%d",&num);
	for(i=1;i<=num;i++)
	{
		scanf("%d%d",&p,&q);
		printf("%d\n",apple(p,q));
	}
	return 0;
}

int apple(int m,int n)
{
	int sum=0,j;
	if(m==0) return 1;
	if(m<n) return apple(m,m);
	if(m>=n)
	{
		for(j=n;j>0;j--)
			sum+=apple(m-j,j);
		return sum;
	}
}


int C(int m,int n)
{
	if(m==0||n==m)
		return 1;
	return C(m,n-1)+C(m-1,n-1);
}

int f(int M, int N)
{
	if(N==1)
		return 1;
	if(M==0)
		return 1;
	if(N>M)
		return f(M,N-1);
	if(M>=N)
		return f(M,N-1)+f(M-N,N);
}

int main()
{
	int n, M, N, i;
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%d%d", &M, &N);

		printf("%d\n", f(M,N));
	}
	return 0;
}


int fangfa(int m,int n)
{
	if(n==1)
		return 1;
	if(m>n)
		return(fangfa(m,n-1)+fangfa(m-n,n));
	else if(m==n)
		return(fangfa(m,n-1)+1);
	else
		return(fangfa(m,n-1));
}
void apple()
{
	int m=0,n=0;
	scanf("%d%d",&m,&n);
	printf("%d\n",fangfa(m,n));
}
void main()
{
	int t=0,i=0;
	scanf("%d",&t);
	for(i=0;i<t;i++)
		apple();
}


int f(int m,int n);
int f1(int m,int n)         //?????????
{
    if(n==1)
    return 0;
    else
    return f(m,n-1);
    }
int f2(int m,int n)         //???????
{
    if(m<n)
    return 0;
    else if(m==n)
    return 1;
    else
    return f(m-n,n);
    }
int f(int m,int n)
{
    return f1(m,n)+f2(m,n);
    }
main()
{
    int i,m,n,t;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",f(m,n));
        }
    }


int find(int m, int n);
int main()
{
	int t, m, n;
	scanf("%d", &t);
	while (--t >= 0)
	{
		scanf("%d%d", &m, &n);
		printf("%d\n", find(m, n));
	}
	return 0;
}
int find(int m, int n)
{
	if (n == 1)
		return 1;
	else if (m == n)
		return find(m, n - 1) + 1;
	else if (n > m)
		return find(m, m);
	else
		return find(m, n - 1) + find(m - n, n);
}


int fun(int m,int n,int j);
int main(void)
{ int n,m,s,t;
scanf("%d\n",&t);
while(t>0){
scanf("%d %d\n",&m,&n);
if(n>m) n=m;
s=fun(m,n,0);
printf("%d\n",s);
t--;
}
}
int fun(int m,int n,int j)
{ int i,s=0;
if(n==1) return m>=j;
for(i=j;i<m;i++) s+=fun(m-i,n-1,i);

return s;
}


int hanshu(int n,int M)
{
	if(n==1)return 1;
	int a;
	if(M<n)a=0;
	if(M==n)a=1;
	if(M>n)a=hanshu(n,M-n);
	return hanshu(n-1,M)+a;
}
int main()
{
	int t,M,N,i;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
	    scanf("%d %d",&M,&N);
	    printf("%d\n",hanshu(N,M));
	}

}


int xx(int m,int n)
{
	int x=0;
	if(m<0)x=0;
	else if(n==1||m==0)
		x+=1;
	else
	x+=xx(m,n-1)+xx(m-n,n);
	return(x);
}
void main()
{
	int n,i,a,b;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		printf("%d\n",xx(a,b));
	}
}


int reverse (int m,int n)
{
	int back=0;
	if((m==1 || n==1)||(m==0))
	{
		back=1;
		return 1;
	}
	if(m>=n)
	{
		back += reverse(m-n,n);
		back += reverse(m,n-1);
	}
	else if(m<n)
	{
		back += reverse(m,n-1);
	}
	return back;
}

int main()
{
	int a,b,i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		printf("%d\n",reverse(a,b));
	}
	return 0;
}


int Calc(int m, int n)
{
	int sum;

	// case: at least one empty
	if (n == 1)
		return 1;
	else
		sum = Calc(m, n - 1);

	// case: no empty
	if (m == n)
		sum += 1;
	else if (m > n)
		sum += Calc(m - n, n);

	return sum;
}

int main()
{
	int m, n, x;
	for(cin >> x; x > 0; x--)
	{
		cin >> m >> n;;
		cout << Calc(m, n) << endl;
	}
}


void main()
{
	int num1(int m,int n);
	int t,m,n,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m,&n);
		printf("%d\n",num1(m,n));
	}
}
int num1(int m,int n)
{
	int b,c,z;
	if(m==1||n==1||m==0)
		z=1;
	else
	{
		if(m<n)
			z=num1(m,m);
		else
		{
			b=num1(m,n-1);
		    c=num1(m-n,n);
			z=b+c;
		}
	}
		return(z);
}


int ways(int apple,int plate)
{
	int waynumber;
	if(plate==1||apple==1||apple==0)
		waynumber=1;
	else if(apple<plate)
		waynumber=ways(apple,apple);
	else waynumber=ways(apple,plate-1)+ways(apple-plate,plate);
	return waynumber;
}
int main()
{
	int applenumber[20],platenumber[20],n,i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d%d",&applenumber[i],&platenumber[i]);
	for(i=0;i<n;i++)
		printf("%d\n",ways(applenumber[i],platenumber[i]));
	return 0;
}


int sum;
int main()
{
	void pingguo();
	int t;
	scanf("%d",&t);
	int i;
	for(i=0;i<t;i++)
	{
		pingguo();
	}
	return 0;
}
void pingguo()
{
	sum=0;
	void func(int,int);
	int apple,plate;
	scanf("%d %d",&apple,&plate);
	func(apple,plate);
	printf("%d\n",sum);
}
void func(int apple,int plate)
{
	if(apple==0||plate==1)
	{
		sum++;
	}
	else
	{
		if(plate>apple)
		{
			func(apple,apple);
		}
		else
		{
			func(apple-plate,plate);
			func(apple,plate-1);
		}
	}
}


int way(int m,int n);
int main()
{
    int N,m,n;
    cin>>N;
    for(int i=0;i<N;i++)
    {
            cin>>m>>n;
            cout<<way(m,n)<<endl;
    }
}
int way(int m,int n)
{
    if(n==1)return 1;
    else if(m==n)return way(m,n-1)+1;
    else if(m<n)return way(m,m);
    else return way(m,n-1)+way(m-n,n);
}


int digui(int m,int n)
{
	if(m<n)
		return digui(m,m);
	else
	{
		if(m==0||n==1)
			return(1);
		else return(digui(m,n-1)+digui(m-n,n));
	}
}
void main()
{
	int m,n,t,i,a[20],b[20],c[20],p,q;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&b[i],&c[i]);
		p=b[i];q=c[i];
		a[i]=digui(p,q);
	}
	printf("%d",a[0]);
	if(t>=1)
	for(i=1;i<t;i++)
	printf("\n%d",a[i]);
}


int mustput(int m,int n)
{
    int put(int m,int n);
    int c,d=m-n;
    if(n==1)
    {
            c=1;
    }
    else
    {
        c=put(d,n);
    }
    return c;
}
int min(int m,int n)
{
    if(m>=n)
    {
        return n;
    }
    else
    {
        return m;
    }
}
int put(int m,int n)
{

    int c=0;
    int i;
    if(m==0)
    {
        c=1;
    }
    for(i=1;i<=min(m,n);i++)
    {
        c=c+mustput(m,i);
    }
    return c;
}
int main()
{
     int m,n,l;
     scanf("%d",&l);
     for(int i=1;i<=l;i++)
     {
         scanf("%d %d",&m,&n);
         printf("%d\n",put(m,n));
     }

}


int num(int m,int n);
int num1(int m,int n);
int num2(int m,int n);
int main()
{
	int m,n,k,i;
	scanf("%d",&k);
	for(i=1;i<=k;i++)
	{
    scanf("%d%d",&m,&n);
	printf("%d\n",num(m,n));
	}
return 0;
}

int num(int m,int n)
{return(num1(m,n)+num2(m,n));}
int num1(int m,int n)    //full
{
	if(m==n)return(1);
	else if(n==1)return(1);
	else if(m<n)return(0);
	else return(num(m-n,n));
}
int num2(int m,int n)   //empty
{
	if(m==1)return(1);
	if(n==1)return(0);
	else return(num(m,n-1));
}


int f(int, int);
int f_n(int, int);
int f_e(int, int);

int f(int x, int y){
	if (x == 1) return 1;
	return f_e(x, y) + f_n(x, y);
}

int f_e(int x, int y){
	return f(x-1, y);
}

int f_n(int x, int y){
	if (y < x) return 0;
	return f(x, y-x);
}

int main() {
	int n, x, y;
	cin >> n;
	for (int i = 0; i < n; i ++) {
		cin >> y >> x;
		cout << f(x, y) << endl;
	}
	return 0;
}


int  cal(int x,int y)
{
   int i,sum;
   if ((x<0)||(y==0)) return 0;

   if (x==0) return 1;
   if (y==1) return 1;

   else return cal(x-y,y)+cal(x,y-1);

   return sum;
}
int main()
{
    int n,m,i,l;
    scanf("%d",&l);
    for (i=1;i<=l;i++)
   {
      scanf("%d%d",&m,&n);
      printf("%d",cal(m,n));
      if (i!=l) printf("\n");
    }

    return 0;
}


int f(int,int);
void main()
{
	int t;
	scanf("%d",&t);
	int i;
	for(i=0;i<t;i++)
	{
		int m,n,a;
		scanf("%d %d",&m,&n);
		a=f(m,n);
		printf("%d\n",a);
	}
}
int f(int a,int b)
{
	if(a<0) return(0);
	else if(b<0) return(0);
	else if(a==1||b==1) return(1);
	else
	{
		int s;
		s=f(a,b-1)+f(a-b,b);
		return(s);
	}
}


int apple(int m, int n)
{
    if(m<n&&m!=0&&n>1)
    {
           return apple(m,n-1);
    }
    else if(m>=n&&m!=0&&n>1)
    {
           return apple(m,n-1)+apple(m-n,n);
    }
    else if(m==0)
    return 1;
    else if(n==1&&m!=0)
    return 1;
}
main()
{
      int t,i,m,n;
      scanf("%d",&t);
      for(i=0;i<t;i++)
      {
                      scanf("%d %d",&m,&n);
                      printf("%d\n",apple(m,n));
      }
}


int F(int m,int n)
{
    if(m==0||m==1) return 1;
    if(n==0||n==1) return 1;
    if(m<n)
		return F(m,m);
    else
		return F(m-n,n)+F(m,n-1);
}
int main()
{
    int m[20] , n[20] , i;
	int t;
	cin >> t;
	for(i = 0 ; i < t ; i++)
		cin >> m[i] >> n[i];
    for(i = 0 ; i < t ; i++)
		cout << F(m[i],n[i]) << endl;
	return 0;
}


int n=0;
int digui(int M, int N)
{
  if(N==1)
  {
    return n+1;
  }
  else if(M==1)
  {
    return n+1;
  }
  else
  {
    if(M>N) return digui(M-1,N);
    else return digui(M-1,N)+digui(M,N-M);
  }
}

int main()
{
  int M,N,n,i,K;
  scanf("%d",&n);
  for(i=1;i<=n;++i)
  {
    scanf("%d%d",&N,&M);
    K=digui(M,N);
    printf("%d\n",K);
  }
  return 0;
}


int baifang(int m,int n);
int main()
{
 	int t,m,n,i;
 	scanf("%d",&t);
 	for(i=1;i<=t;i++){
		scanf("%d %d",&m,&n);
		printf("%d\n",baifang(m,n));
		}
}
int baifang(int m,int n){
	int i,r;
	if(n==1) return 1;
	if(m==1) return 1;
	if(m<n){
		r=baifang(m,n-1);
		}
	else{
		r=baifang(m,n-1)+baifang(m-n,n);
		}
	return r;
	}


int waynum(int m, int n)
{
	if (n == 1 || m == 1 || m == 0)
		return 1;
	else if (m <= 0)
		return 0;
	else
		return (waynum(m, n - 1) + waynum(m - n, n));
}
int main()
{
	int a, m, n;
	cin >> a;
	while (a --)
	{
		cin >> m >> n;
		cout << waynum(m, n) << endl;
	}
	return 0;
}


int main()
{
    int f(int m,int n);
    int a[20],b[20],t,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    scanf("%d %d",&a[i],&b[i]);
    for(i=0;i<t;i++)
		printf("%d\n",f(a[i],b[i]));
    return 0;
}
    int f(int m,int n)
 {
     int c;
    if(m!=1&&n==1) c=1;
	else if(m==1&&n!=1) c=1;
      else if(m==1&&n==1)c=1;
	  else if(m>n) c=f(m-n,n)+f(m,n-1);
	  else if(m==n) c=1+f(m,n-1);
	  else if(m<n) c=f(m,m);
     return(c);
}


int k=0,t;
void main()
{
	void apple(int a[],int b[],int c[]);
	int M[100],N[100],s[100]={0},i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
		scanf("%d%d",&M[i],&N[i]);
	apple(M,N,s);
	printf("%d",s[0]);
	for(i=1;i<t;i++)
		printf("\n%d",s[i]);
}
void apple(int a[],int b[],int c[])
{
	int i;
	int num(int a,int b);
	for(i=0;i<t;i++)
		c[i]=num(a[i],b[i]);
}
int num(int a,int b)
{
	if(a<b)
	{
		b=a;
		k=num(a,b);
	}
	else
		if(b==1||a==0)
			k=1;
		else if(b>1)
			k=num(a,b-1)+num(a-b,b);
	return(k);
}


int main()
{
	int empty (int m,int n);
	int full (int m,int n);
	int i;int n;int num[20][2];int z[20];

	scanf("%d",&n);
	for(i=0;i<=n-1;i++)
	{
	scanf("%d %d",&num[i][1],&num[i][0]);
    z[i]=full(num[i][0],num[i][1])+empty(num[i][0],num[i][1]);
	}
	for(i=0;i<=n-1;i++)
	printf("%d\n",z[i]);
	return 0;
}
int full (int m,int n)
{
	int empty (int m,int n);
	int result;
	if(m<n) result=full(m,n-m)+empty(m,n-m);
	if(m==n) result=1;
	if(m>n) result=0;
	return(result);
}
int empty (int m,int n)
{
int result;
if(m==1) result=0;
else result=full(m-1,n)+empty(m-1,n);
return(result);
}


int main()
{
    int Q(int x,int y);
    int a[20],b[20],c[20];
    int t,i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
        c[i]=Q(a[i],b[i]);

    }
    for(i=0;i<t;i++)
    {
        printf("%d\n",c[i]);
    }
}
int Q(int x,int y)
{
    if(x==1||y==1)
    {
        return 1;

    }
    else if(x<y)
    return(1+Q(x,x-1));
    else if(x==y)
    return(1+Q(x,y-1));
    else if(x>y)
    return(Q(x,y-1)+Q(x-y,y));
}


int put(int, int);
int main()
{
	int nLoop;
	int m,n;
	scanf("%d", &nLoop);
	while(nLoop--)
	{
		scanf("%d %d", &m, &n);
		printf("%d\n",put(m,n));
	}
	return 0;
}
int put(int m, int n)
{
	if(m==0 || m==1 || n==1) return 1;
	int sum = 1, i;
	for(i=2;i<=n&&i<=m;i++)
		sum += put(m-i,i);
	return sum;
}


int f(int a,int b)
{
    if (b==1) {return 1;}
    if (a<0) {return 0;}
    else {return f(a-b,b)+f(a,b-1);}
}
int main ()
{
    int w,m,n;
    scanf ("%d",&w);
    for (;w>0;w--)
    {
        scanf ("%d %d",&m,&n);
        printf("%d\n",f(m,n));
    }
}


void apple(int, int, int);
int sum;

int main()
{
	int t, m, n;
	cin >> t;
	for(int i = 0; i < t; i++)
	{
		sum = 0;
		cin >> m >> n;
		apple(0, m, n);
		cout << sum << endl;
	}
	return 0;
}

void apple(int s, int x, int y)
{
	int i;
	if(y == 1)
	{
		sum++;
	}
	else
	{
		for(i = s; i <= x/y; i++)
		{
			apple(i, x - i, y - 1);
		}
	}
}


int main()
{
    int apple(int x,int y);
    int i,t,m,n;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",apple(m,n));
    }
    return 0;
}
int apple(int x,int y)
{
    int p=0;
    if(y==1) p=1;
    else if(x>y) p=apple(x,y-1)+apple(x-y,y);
    else if(x==y) p=apple(x,y-1)+1;
    else p=apple(x,y-1);
    return(p);
}


int a(int m,int n);
main()
{

	int t,i;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		int p,q;
		scanf("%d%d",&p,&q);
		printf("%d\n",a(p,q));
	}
	return 0;
}
int a(int m,int n)
{
	if(m<n)
	{
		return a(m,n-1);
	}
	else if(n==m&&n!=1)
	{
		return a(m,n-1)+1;
	}
	else
	{if(n==1)
	{
		return 1;
	}
	else
	{
		return a(m-n,n)+a(m,n-1);
	}
	}
}


int full (int M, int N);
int empty (int M,int N);
int main()
{
	int t, M, N, i, num;
	cin >> t;
	for (i = 0; i < t; i++)
		{
			cin >> M >> N;
			cout << full(M , N) + empty(M , N) << endl;
		}
	return 0;
}
int full (int M, int N)
{
	if ( M < N )
		return 0;
	if ( M == N )
		return 1;
	if ( M > N )
	{
		return( full( M - N ,N ) + empty (M - N, N) );
	}

}
int empty (int M,int N)
{
	if (N == 2)
		return 1;
	if (N == 1)
		return 0;
	if (N != 1 && N != 2)
	return (full( M, N - 1) + empty(M, N - 1));

}


int way (int,int);
int main()
{
	int n;
	int t[2];
	cin>>n;
	while ( n-- )
	{
		cin>>t[0]>>t[1];
		cout<<way(t[0],t[1])<<endl;
	}
}
int way(int a,int b)
{
	if ( b == 1 || a == 1 || a== 0 )
		return 1;
	if ( a >= b )
		return way( a , b - 1 ) + way( a - b , b );
	if ( a < b )
		return way( a , a );
}


int zhonglei(int m,int n)
{
	int temp;
	if(m==0)
		return 1;
	else if(m==1)
		return 1;
	else if(n==1)
		return 1;
	else if (m<0)
		return 0;
	else
	{
		temp=zhonglei(m-n,n);
	    temp=temp+zhonglei(m,n-1);
	    return temp;
	}
}
int main()
{
	int t,i,tm,tn,tk;
	cin>>t;
	for(i=0;i<t;i++)
	{
		cin>>tm>>tn;
		tk=zhonglei(tm,tn);
		cout<<tk<<endl;
	}
	return 0;
}


int apple(int m,int n);
int maxapple(int m,int n){
if(m==n)
return 1;
if(n==1)
return 1;
else return apple(m-n,n);}
int minapple(int m,int n){
if(n==2)
return 1;
if(n==1)
return 0;
else
return apple(m,n-1);
}
int apple(int m,int n){
if(m<1||n<1)
return 0;
if(n==1)
return 1;
else
return maxapple(m,n)+minapple(m,n);
}
int main(){
int i,k,m,n;
cin>>k;
for(i=1;i<=k-1;i++){
cin>>m>>n;
cout<<apple(m,n)<<endl;}
cin>>m>>n;
cout<<apple(m,n);
}


int f(int m,int n)
{
	if(n==1)
	{
		return 1;
	}
	if(m>=n)
	{
		return f(m,n-1)+f(m-n,n);
	}
	else
	{
		return f(m,n-1);
	}
}
int main()
{
	int n,m,t,i,k;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
	{
		scanf("%d %d",&m,&n);
		k=f(m,n);
		printf("%d",k);
		printf("\n");
	}
	return 0;
}


int ways(int,int);
int main()
{
	int m,n,k,t;
	cin>>t;
	while ( t-- )
	{
		cin>>m>>n;
		k=ways(m,n);
		cout<<k<<endl;
	}
	return 0;
}
int ways( int a,int b )
{
	if ( ( a == 0 ) || ( b == 1 ) )
	{
		return 1;
	}
	if ( ( a < 0 ) || ( b <= 0 ) )
	{
		return 0;
	}
	return ( ways( a-b,b ) + ways ( a,b-1 ) );
}


int function(int m,int n)
{
	int sum=0;
    if (m==0||m==1||n==1)
    return 1;
    else if (m<0)
	return 0;
    else sum=sum+function(m,n-1)+function(m-n,n);
    return sum;
}

void main()
{
	int t,i,M[20],N[20];

	scanf("%d",&t);
	for(i=0;i<=t-1;i++)
	{
		scanf("%d%d",&M[i],&N[i]);
	}

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


int ap(int x,int y)
{
	if(y==1||x==1)
	{
		return 1;
	}
	else if(y==2)
	{
		return 1+x/2;
	}
	else if(x<=y)
	{
		return (1+ap(x,x-1));
	}
	else
	{
		return (ap((x-y),y)+ap(x,(y-1)));
	}
}
int main()
{
	int n;
	scanf("%d",&n);
	int a,b,i;
	for(i=0;i<n;i++)
	{
	    scanf("%d%d",&a,&b);
		printf("%d\n",ap(a,b));
	}
	return 0;
}


int a(int m,int n)
{
	int c;
	 if(m == 1 || n== 1 || m == 0) return 1;
	 if(m<n)    return a(m, m);
	 else return a(m-n,n)+a(m,n-1);
}
main()
{
	int m[20],n[20],k,c,i;
	scanf("%d\n",&k);

	for(i=0;i<k;i++)
	{
		scanf("%d %d",&m[i],&n[i]);
		c=a(m[i],n[i]);
		printf("%d\n",c);
	}
}


int apple(int x,int y)
{
  int k;
  if(y==1)   k=1;
  else
   {if(x>y)   k=apple(x-y,y)+apple(x,y-1);
    if(x<y)   k=apple(x,y-1);
    if(x==y)   k=1+apple(x,y-1);}
 return(k);
 }
void main()
{
  int i,a,m[50],n[50];
  scanf("%d\n",&a);
  for(i=0;i<a;i++) scanf("%d %d\n",&m[i],&n[i]);
  for(i=0;i<a;i++)  printf("%d\n",apple(m[i],n[i]));
return(0);
}


int count(int,int);
int main()
{

	int num;
	cin>>num;
	for(int i=0;i<num;i++)
		{
			int m,n;
			cin>>m>>n;
			cout<<count(m,n)<<endl;
		}
	return 0;
}
int count(int m,int n)
{
	if(n==1||m==0)
		return 1;
	if(n>m)
		return count(m,m);
	return count(m,n-1)+count(m-n,n);
}


/*??(15-11) ?????*/

int types(int m,int n);

int full(int m,int n)//m?????n???
{
	if(m<=n || n==1) return 1;
	else
	{
		return types(m-n,n);
	}
}

int types(int m,int n)//m?????n???
{
	int num=0;
	int i;
	if(m<n) return types(m,m);
	else
	{
		for(i=0;i<n;i++) num=num+full(m,n-i);
		return num;
	}
}

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
    	int m,n;
    	cin>>m>>n;
    	cout<<types(m,n)<<endl;
    }
	return 0;
}


int sum;
int work(int n,int m)
{
    if(m>n) m=n;
    if(n==1||m==1) return 1;
    if(n!=0&&m==0)  return 0;
    if(n==0&&m!=0)  return 0;
    if(n==0&&m==0)  return 1;
    return  work(n-m,m)+work(n,m-1);
}
int main()
{
    int a,b,c,i;
    scanf("%d",&c);
    for(i=1;i<=c;i++)
    {
    scanf("%d %d",&a,&b);
    printf("%d\n",work(a,b));
    }
}


int fang(int m,int n,int j)
{
    int a=0,k,i;
    if(n==1)
    return m>=j;
    else if(n<=m)
    {
    for(k=j;k<m;k++)
    {
         a+=fang(m-k,n-1,k);
    }
    }
    else if(n>m)
    {
         n=m;
         for(k=j;k<m;k++)
         {
                         a+=fang(m-k,n-1,k);
         }
    }
    return a;
}

int main()
{
    int t,M[20],N[20],k[20],i;
    scanf("%d",&t);
    for(i=0;i<t;i++)
    {
                    scanf("%d %d",&M[i],&N[i]);
                    k[i]=fang(M[i],N[i],0);
    }
    for(i=0;i<t;i++)
    {
                    printf("%d\n",k[i]);
    }
    return 0;
}


int f(int m,int n)
{
    if(m<0) return 0;
    else if(n==1) return 1;
    else return f(m,n-1)+f(m-n,n);
}
main()
{
      int t,m,n,i,j,g;
      scanf("%d",&t);
      for(g=0;g<t;g++)
      {
                      scanf("%d %d",&m,&n);
                      printf("%d\n",f(m,n));
      }
}


/*???
???*/
int sum(int m, int n, int lim)//m????n???????????
{
	if(n == 1 && m <= lim)
		return 1;
	if(n == 1 && m > lim)
		return 0;
	if (m == 0)
		return 1;
	int max, i, a;
	if(m % n == 0)
		max = m / n;
	else
		max = m / n + 1;

	a = 0;
	if(lim > m)
		lim = m;
	for (i = lim; i >= max; i--)
		a += sum(m - i, n - 1, i);
	return a;
}
int main ()
{
	int m, n, k, i;
	cin >> k;
	for(i = 1; i <= k; i++)
	{
		cin >> m >> n;
		cout << sum(m,n,m) << endl;
	}
	return 0;
}


int main(int argc, char *argv[])
{
  int i,t,m,n;
  scanf("%d",&t);
  for(i=0;i<=t-1;i++)
  {
      scanf("%d %d",&m,&n);
      printf("%d",f(m,n));
      if(i!=t-1) printf("\n");
  }

  return 0;
}

int f(int m,int n)
{
     int x=0;
     if(m<0) x+=0;
     else if(m==0) x+=1;
     else if(n>1) x+=f(m,n-1)+f(m-n,n);
     else if(n==1) x+=1;
     return x;
}


int search(int x,int y,int z)
{
	int s=0,i;
	if(y>1)
		for(i=z;i<=x/y;i++)
			s+=search(x-i,y-1,i);
	else s=1;
	return s;
}

int main()
{
	int t,M,N,i;
	cin>>t;
	for(i=0;i<t;i++)
	{
		cin>>M>>N;
		cout<<search(M,N,0)<<endl;
	}
	return 0;
}


int f (int x,int y){
	int result;
	if(y==1||x==1||x==0)
		return 1;
	else if(x-y<0)
		return f(x,x);
	else
	{	result=f(x,y-1)+f(x-y,y);
	return result;}
}
int main(){
 int M,N,n,r,i;
 scanf("%d",&n);
 for(i=0;i<n;i++){
	 scanf("%d %d",&M,&N);
	 r=f(M,N);
	 printf("%d\n",r);
 }
 return 0;
}


int f(int m,int n){
    if(m<n)return f(m,m);
    if(m==1||n==1||!n)return 1;//??? m>=1
    if(m>=n)return f(m-n,n)+f(m,n-1);
}
int main(){
    int m,n,t;
    cin>>t;
    while(t--){
        cin>>m>>n;
        cout<<f(m,n)<<endl;
    }
}


int PlaceApple(int,int);
int main()
{
	int Apple,Plate,t;
	cin>>t;
	while(t--)
	{
		cin>>Apple>>Plate;
		cout<<PlaceApple(Apple,Plate)<<endl;
	}
}
int PlaceApple(int AppleNumber, int PlateNumber)
{
    if(AppleNumber < 0 || PlateNumber == 0)
        return 0;
    if(AppleNumber == 1 || AppleNumber == 0 || PlateNumber == 1)
        return 1;
    int sum=0;
    for(int i = 0; i <= AppleNumber/PlateNumber; i++)
        sum += PlaceApple(AppleNumber - PlateNumber *i, PlateNumber - 1);
    return sum;
}


int f(int x,int y)
{
 if(x<y)
  y=x;
 if(x==0)
  return 1;
 if(y==1)
  return 1;
 if(x>=y)
  return f(x,y-1)+f(x-y,y);
  return 0;
}
main()
{
 int t,n,m;
 scanf("%d",&t);
 while(t--)
 {
  scanf("%d %d",&m,&n);
  printf("%d\n",f(m,n));
 }
}


int main()
{char zi[105],shuzu[105];
int i,j;
gets(zi);
for(i=0;i<=strlen(zi)-1;i++)
{shuzu[i]=zi[i]+zi[i+1];}
shuzu[i-1]=zi[0]+zi[i-1];
for(i=0;i<=strlen(zi)-1;i++)
{printf("%c",shuzu[i]);}

getchar();
getchar();

}


int main()
{
	char org[200];
	char *p;
	p=org;
	int i,m,n;
	gets(org);
	n=strlen(org);
	for(i=0;i<n-1;i++)
	{

		m=*(p+i)+*(p+1+i);
		printf("%c",m);
	}
	m=*(p+i)+*p;
	printf("%c",m);
}


char *calc(char *ps,char *pt)
{
	int i,m=strlen(ps);
	for(i=0;i<m-1;i++)
		*(pt+i)=*(ps+i)+*(ps+i+1);
	*(pt+m-1)=*(ps+m-1)+*(ps+0);
	return pt;
}
int main()
{
	char s[101],c[101]={'\0'};
	gets(s);
	printf("%s\n",calc(s,c));
	return 0;
}


int main()
{
	char c[110], ch[110];
	cin.getline(c,110);
	int len = strlen(c);
	for (int i = 0; i < len - 1; i++)
		ch[i] = c[i] + c[i + 1];
	ch[len - 1] = c[len - 1] + c[0];
	for (int j = 0; j < len; j++)
		cout << ch[j];
	cout << endl;
	return 0;
}


int main()
{
	int len,i;
	char str[100];
	gets(str);
	len=strlen(str);
	for(i=0;i<len;i++)
	{
		if(i!=len-1)
		{
			printf("%c",str[i]+str[i+1]);
		}else{
			printf("%c",str[len-1]+str[0]);
		}
	}
	return 0;
}


int main()
{
	int i=0,l=0;
	char zfc[LEN],Friend[LEN];
	gets(zfc);
	l=strlen(zfc);
	//printf("%d",l);
	for(i=0;i<l;i++)
	{
		if(i+1<l)
		{
		  Friend[i]=zfc[i]+zfc[i+1];
		  printf("%c",Friend[i]);
		}
		if(i==l-1)
		{
	      Friend[i]=zfc[i]+zfc[0];
		  printf("%c",Friend[i]);
		}
	}
	return 0;
}


int main(int argc, char *argv[])
{
    char a[101];
    gets(a);
    int i;
    for(i=1;i<=strlen(a)-1;i++)
    printf("%c",a[i-1]+a[i]);
    printf("%c",a[strlen(a)-1]+a[0]);
    return 0;
}


int main()
{
	char s[101],c;
	int len,i,asc1,asc2;
	gets(s);
	len=strlen(s);

	for(i=0;i<len-1;i++)
	{
		asc1=s[i];
		asc2=s[i+1];
		c=asc1+asc2;
		printf("%c",c);
	}

	asc1=s[len-1];
	asc2=s[0];
	c=asc1+asc2;
	printf("%c",c);

	return 0;
}


int main()
{
    char* s;
    char ch[101];
    char c;
    int i;
    s=ch;
    gets(ch);
    for(i=0;i<strlen(ch)-1;i++)
    {
           c=*(s+i)+*(s+i+1);
           printf("%c",c);
    }
    c=*s+*(s+strlen(ch)-1);
    printf("%c",c);
     return 0;
}


int main()
{
	char str[101];
	char *p = str;
	cin.getline(str, sizeof(str));
	char str_new[101];
	char *q = str_new;
	int length;
	length = strlen(str);
	for(p = str, q = str_new; p <= str + length - 1; p++, q++)
		*q = *p + *(p + 1);
	*(str_new + length - 1) = *(str + length - 1) + *str;
	*(str_new + length) = '\0';
	cout << str_new << endl;
	return 0;
}


void P(char a,char b)
{
	int m,n;
	m=a;
	n=b;
	printf("%c",m+n);
}
int main()
{
	int i,n,a,b;
	char str[100];
	gets(str);
	n=strlen(str);
	for(i=0;i<n-1;i++)
	{
		P(str[i],str[i+1]);
	}
	a=str[0];
	b=str[n-1];
	printf("%c",a+b);
	return 0;
}


int main()
{
	char *s = (char*)malloc(101*sizeof(char));
	gets(s);
	int i=0;
	for(i=0;i<strlen(s);i++){
		if(i<strlen(s)-1)
			printf("%c",(char)(*(s+i)+*(s+i+1)));
		else
			printf("%c\n",(char)(*(s+i)+*s));
	}

	return 0;
}


void main()
{
   char *p,*a,*b;
   p=(char *)malloc(200*sizeof(char));
   gets(p);
   for(a=p,b=p+1;b<p+strlen(p);a++,b++)
	   printf("%c",*a+*b);
   printf("%c",*p+*a);
}


int main(int argc, char* argv[])
{
	char c[100],ans[100]={0};
	gets(c);
	int n=strlen(c),i=0;
	for(i=0;i<n;i++)
	{
		if(i!=n-1)
		{ans[i]=c[i]+c[i+1];}
		else ans[i]=c[i]+c[0];
		printf("%c",ans[i]);
	}
	return 0;
}


int main()
{
	char s[101], *p;
	int i;
	cin.getline(s, 101);
	int l = strlen(s);
	p = s;
	for (i = 0;i < l - 1;i++)
	{
		char a = p[i] + p[i + 1];
		cout << a;
	}
	char b =  p[0] + p[l - 1];
	cout << b;

	return 0;
}


int main()
{
	char x[100];
	int a[100],i,n;
	char str[100];
	gets(str);
	n=strlen(str);
	for(i=1;i<n;i++)
	{
		a[i]=str[i-1]+str[i];
	}
	a[n]=str[0]+str[n-1];
	for(i=1;i<=n;i++)
	{
		printf("%c",a[i]);
	}
	return 0;
}


int main()
{
	char str[101],*p=str,*ps=str;
	gets(str);
	for(;p<str+strlen(str)-1;p++)
	{
		printf("%c",*p+*(p+1));
	}
	printf("%c",*p+*ps);
	return 0;
}


void friends(char *p, int len)
{
	int i;
	char  m = *p;
	for (i = 0; i < len - 1; i++)
		*(p + i) += *(p + i + 1);
	*(p + len - 1) += m;
}

int main()
{
	char a[105];
	cin.getline(a,101);
	int len = strlen(a);
	friends(a, len);
	cout << a << endl;
	return 0;
}


/*
 * 15.cpp
 *
 *  Created on: 2013-12-8
 *      Author: Administrator
 */

int main()
{
	int s;
	char *p=NULL,*q=NULL;
	char a[200],b[200];
	cin.getline(a,200);//?????
	s=strlen(a);
	for(p=a,q=b;p<a+s;p++,q++)
	{
		if(p==a+s-1)
		  *q=*p+*a;
		else
		  *q=*p+*(p+1);//????
      cout<<*q;
	}
return 0;
}


int main()
{
	char a[1000];
	cin.getline(a,1000);
	char f=a[0];
	int i=0;
	while(a[i+1])
		a[i++]=a[i]+a[i+1];
	a[i]+=f;
	cout<<a;

	return 0;
}


main()
{
	int n,i,j,k,len;
	char a,b;
	char *name,*final;
	name=(char*)malloc(101*sizeof(char));
	final=(char*)malloc(101*sizeof(char));
	gets(name);
	len=strlen(name);
	for(i=0;i<len-1;i++)
	{
		a=*(name+i);
		b=*(name+i+1);
		*(final+i)=a+b;
	}
	a=*(name+i);
	b=*(name);
	*(final+i)=a+b;
	*(final+len)='\0';
	printf("%s\n",final);
}


int main()
{
  char s[1000],s1[1000]={'\0'};
  int i,j,n;
  void change(char s[],char s1[],int n);
  gets(s);
  change(s,s1,strlen(s));
  puts(s1);
  return 0;
}
 void change(char s[],char s1[],int n)
 {
  int i;
  char*p=s;
  for(i=0;i<n-1;i++,p++)
   s1[i]=*p+*(p+1);
  s1[n-1]=*s+s[n-1];
}


int main()
{
    char c[210],qinpeng[210];
    int i,j;
    gets(c);
    for(i=0;i<(strlen(c)-1);i++)
    {
                            qinpeng[i]=c[i]+c[i+1];
    }
    qinpeng[strlen(c)-1]=c[0]+c[strlen(c)-1];
    qinpeng[strlen(c)]='\0';
    printf("%s\n",qinpeng);
    return 0;
}


int main(){
	char s[101];
	char qinpeng[101];
	int i,j,l,a,b;
	char c;
	gets(s);
	//getchar();
	l=strlen(s);
	for(i=0;i<l-1;i++){
		a=*(s+i);
		b=*(s+i+1);
		*(qinpeng+i)=a+b;
	}
	a=*(s);
	b=*(s+l-1);
	*(qinpeng+l-1)=a+b;
	*(qinpeng+l)='\0';
	puts(qinpeng);

	return 0;
}


void main()
{
	char *p;
	p=(char *)malloc(1000*sizeof(char));
	gets(p);
	int i;
	int L=strlen(p);
	for(i=0;i<L-1;i++)
		printf("%c",*(p+i)+*(p+i+1));
	printf("%c\n",*(p+L-1)+*p);
}


int main()
{
char a[200];
cin.getline(a,101);
int b=strlen(a);
char *p=a;
for(int i=0;i<b;i++)
cout<<(char)(*(p+i)+*(p+(i+1)%b));
}


int main()
{
	char series[101];
	cin.getline(series, 102);
	char *p = series;
	char initial = *p;
	char trans[101];
	char *q = trans;
	for(; p < series + strlen(series) - 1; p++, q++)
	{
		*q = *p + *(p+1);
	}
	*q = *p + initial;
	*(q+1) = '\0';
	cout << trans << endl;
	return 0;
}


int main()
{
    char s1[1000],s2[1000]={0},temp[1000];
    int i,num[1000];
    while(0==0)
                 {
                            scanf("%s",temp);
                            if(getchar()==' ')
                            {
                            strcat(s1,temp);
                            s1[strlen(s1)]=' ';
                            }
                            else
                            {
                                strcat(s1,temp);
                                break;
                            }
                 }
    for(i=0;i<strlen(s1);i++)
    num[i]=s1[i];
    for(i=0;i<strlen(s1)-1;i++)
    s2[i]=num[i]+num[i+1];
    s2[strlen(s1)-1]=num[strlen(s1)-1]+num[0];
    printf("%s",s2);
    return 0;
}


int relative(int *a,int len,int i);

void main()
{
	char s[MAX];
	int a[MAX];
	int len,i;

	gets(s);
	len=strlen(s);
	for(i=0;i<len;i++)
		*(a+i)=*(s+i);
	for(i=0;i<len;i++)
		printf("%c",relative(a,len,i));
	putchar('\n');
}

int relative(int *a,int len,int i)
{
	int result;
	int *p;
	if(i<len-1){
		p=a+i;
		result=*p+*(p+1);
		return result;
	}
	else{
		p=a+i;
		result=*p+*a;
		return result;
	}
}


void main()
{
	char a[150],b[150];
	int i,len;
	gets(a);
	len=strlen(a);
	for(i=0;i<len;i++)
		if(i!=len-1)b[i]=a[i]+a[i+1];
		else b[i]=a[i]+a[0];
	b[i]=0;
	printf("%s\n",b);
}


int main(int argc, char* argv[])
{
	int i,l;
	char c[101];
	gets(c);
	l=strlen(c);
	for(i=0;i<=l-1;i++){
		printf("%c",c[i]+c[(i+1)%l]);
	}
	return 0;
}


int main(){
   char s[100];
   char *p,c;
   int len;
   gets(s);
   len=strlen(s);
   c=*s;
   for (p=s;p<s+len-1;p++)
	   *p=*p+*(p+1);
       *p=*p+c;
     for (p=s;p<s+len;p++)
    	 cout<<*p;
     return 0;
}


int main()
{
	char s[101], s1[101], *p, *q;
	int i;
	cin.getline(s,101);
	int len = strlen(s);
	p = s;
	q = p;
	for (i = 0; i < len - 1; i++)
	{
		s1[i] = *p + *(p + 1);
		p++;
	}
	s1[len - 1] = *q + *p;
	for (p = s1; p < s1 + len; p++)
		cout << *p;
	cout << endl;
	return 0;
}


int main()
{
	char s[101];
	cin.getline(s,101);
	int length=strlen(s);
	char *p=s;
	for(int i=1;i<length;i++)
	{
		cout<<(char)(*p+*(p+1));
		p++;
	}
	cout<<(char)(*p+*(p-length+1))<<endl;
	return 0;
}


int main()
{
	int n,i;

	char str[101];
	char bud[101];
	gets(str);
	n=strlen(str);
	for(i=0;i<n;i++){
		*(bud+i)=*(str+(i%n))+*(str+((i+1)%n));
	}
	for(i=0;i<n;i++){
		printf("%c",*(bud+i));
	}
	return 0;
}


/*
 * qinpengzifuchuan.cpp
 *
 *  Created on: 2012-12-14
 *      Author: Justin
 */

int main(){
	char a[101],*p,*q,*r;
	cin.getline(a,101);
	int len;
	len=strlen(a);
	for(p=a;p<a+len-1;p++){
		int b;
		b=*p+*(p+1);
		char c;
		c=b;
		cout<<c;
	}
	q=a;r=a+len-1;
	int d=*q+*r;
	char e=d;
	cout<<e;

}


int main()
{
	char a[200],*p=NULL,b;
	cin.getline(a,199);
	p=a;
	do{
		b=*p;
		p++;
		b=b+*p;
		cout <<b;
	}while(*(p+1)!='\0');
	b=*p;
	p=a;
	b=b+*p;
	cout <<b <<endl;
	return 0;
}


int main()
{
	int i;
	char a[130];
	char *p=a;
	gets(a);
	for(i=1;i<strlen(a);i++)
	putchar(*p+*(++p));
	putchar(*p+*a);
	return 0;
}


char *strqp(char *);

int main()
{
    char buffer[101]={0};
	gets(buffer);
	printf("%s\n",strqp(buffer));
	return 0;
}

char *strqp(char *str)
{
	int len;
	len=strlen(str);

	char *qp;
	qp=(char *)malloc(len+1);
	int index=0;
	for(index=0;index<len-1;index++)
		qp[index]=(str[index]+str[index+1]);
	qp[len-1]=str[len-1]+str[0];
	qp[len]='\0';
	return qp;
}


void main()
{void qp(char *p,int n);
char a[105];int l;gets(a);l=strlen(a);
qp(a,l);printf("%c\n",a[0]+a[l-1]);
}
void qp(char *p,int n)
{if(n>=2){printf("%c",*p+p[1]);n--;
qp(p+1,n);}}


int main(){
	char a[111],b[111];
	char *ap=a,*bp=b;
	gets(a);
	for(unsigned int i=0;i<=strlen(a)-2;i++){
		*(bp+i)=*(ap+i)+*(ap+i+1);
	}
	*(bp+strlen(a)-1)=*(ap+strlen(a)-1)+*(ap);
	*(bp+strlen(a))='\0';
	cout<<b;
	return 0;
}


void main()
{
	char zfc[101],newzfc[101]={0};
	char *p,*pn;
	int len;
	pn=newzfc;
	gets(zfc);
	len=strlen(zfc);
	for(p=zfc;p<zfc+len-1;p++){
		*pn=*p+*(p+1);
		pn++;
	}
	p=zfc;
	*pn=*p+*(p+len-1);
	puts(newzfc);
}


int main()
{
    int i,len;
    char word[10000],c;
    gets(word);
    len=strlen(word);
    c=word[0];
    for(i=0;i<len-1;i++)
    word[i]+=word[i+1];
    word[i]+=c;
    printf("%s",word);
   // getch();
    return 0;
}


int main()
{
		char a[102];
		char b[102];
		gets(a);
		int i =0;
		for(;i<strlen(a);i++)
		{
			b[i] = a[i]+a[(i+1)%strlen(a)];
		}
		b[i]='\0';
		printf("%s",b);
		return 0;
}


int main()
{
	int i,len;
	char a[101];
	char b[101]={'\0'};
	char *pa,*pb;

	gets(a);
	len=strlen(a);
	for(pa=a,pb=b;pa<a+len-1;pa++,pb++)
	{
		*pb=*pa+*(pa+1);
	}
	*pb=*pa+*a;
	printf("%s\n",b);
	return 0;
}


int main()
{
	char a[1000];
	int i;
	cin.getline(a,1000);
	int l=strlen(a);
	a[l]=a[0];
	char b[1000];
	for (i=0;i<l;i++)
	{
		b[i]=a[i]+a[i+1];
	}
	for (i=0;i<l;i++)
		cout<<b[i];
	return 0;
}


int main()
{
	char zifu[2][100];
	gets(zifu[0]);
	int t;
	t=strlen(zifu[0]);
	int i,j;
	for (i=0;i<t-1;i++)
	{
		char c;
		char a;
		char b;
		a=zifu[0][i];
		b=zifu[0][i+1];
		c=a+b;
		printf("%c",c);
	}
	char c;
	char a;
	char b;
	a=zifu[0][0];
	b=zifu[0][t-1];
	c=zifu[0][0]+zifu[0][t-1];
	printf("%c",c);

	return 0;

}


int main()
{
	char *string;
	string=(char *)malloc(101);
	gets(string);
	char *p=string;
	int len=strlen(string);
	int i;
	for(i=0;i<len-1;i++)
	{
		printf("%c",*p+*(p+1));
		p++;
	}
	printf("%c",*p+*string);
	return 0;
}


int main()
{
    char a[102];
    cin.getline(a, 102);
    int length = strlen(a);
    int a0 = a[0];
    for (int i = 0; i < length-1; i++) {
        a[i] += a[i+1];
    }
    a[length-1] += a0;
    cout << a;
}


int main()
{
    char s[111];
    char first;
    char *p,*q;
    gets(s);
    p=&s[0];
    q=&s[1];
    first=*p;

    while(*q != '\0')
    {
        cout<<(char)  ((*p) + (*q)) ;
        *p++;
        *q++;
    }
    cout<<(char) (*p+first);

    return 0;
}


int main()
{
	char s[100];
	gets(s);
	char s1[100];
	int i;
	int len;
	len=strlen(s);
	for(i=0;i<len;i++){
		if(i<len-1){
			s1[i]=s[i]+s[i+1];
		}
		else{
			s1[i]=s[i]+s[0];
		}
	}
	for(i=0;i<len;i++){
		printf("%c",s1[i]);
	}
	scanf("%d",&len);
	return 0;
}


int main()
{
	int i,j,k,n;
	char string[200];
	gets(string);
	n=0;
	for (i=1;i<=100;i++)
	{
		if (string[i]!='\0')
		{
			n++;
		}
		else break;
	}
	for (i=0;i<=n-1;i++)
	{
		printf("%c",string[i]+string[i+1]);
	}
	printf("%c",string[n]+string[0]);
	return 0;
}


int main()
{char s[999];
int i,n,t,tt,ttt;
gets(s);
n=strlen(s);
for(i=1;i<=n;i++)
{if(i<n)
{t=s[i-1];
tt=s[i];
ttt=t+tt;
printf("%c",ttt);
}
if(i==n)
{t=s[i-1];
tt=s[0];
ttt=t+tt;
printf("%c",ttt);
}
}
return 0;
}


void f(char a[])
{
    int i = 0;
    for (i = 0; a[i + 1] != '\0'; i++)
        cout << (char)(a[i] + a[i + 1]);
    cout << (char)(a[i] + a[0]);
    cout << endl;
    return;
}
int main()
{
    char a[101];
    cin.getline(a, 101);
    f(a);
    return 0;
}


int main()
{
	char a[1000];
	cin.getline(a,1000);
	int a0=(int) a[0];
	for(int i=0;i<strlen(a)-1;i++)
		cout<<(char)(a[i]+a[i+1]);

	cout<<(char)(a[strlen(a)-1]+a0);
	return 0;
}


main()
{
	char *a;
	a=(char *)malloc(100*sizeof(char));
	gets(a);
	int i,m;
	m=strlen(a);
	for(i=0;i<m-1;i++)
		printf("%c",*(a+i)+*(a+i+1));
	printf("%c",*a+*(a+m-1));
}


int main()
{
	char a[101];
	cin.getline(a,101);
	char *p;
	p = a;
	char b[101];
	int n = strlen(a);
	int i = 0;
	for (i = 0;i < n;i++)
	{
		if (i != n-1)
			b[i] = p[i] + p[i+1];
		else
			b[i] = p[i] + p[0];
	}
	for (i = 0;i < n;i++)
		cout<<(char)(b[i]);
	return 0;
}


int main()
{char str1[103],str2[103];
cin.getline(str1,101);
char *p=str1,*q=str2;
int l=strlen(str1);
for(int i=0;i<l-1;i++)q[i]=p[i]+p[i+1];
q[l-1]=p[l-1]+p[0];
for(int i=0;i<l;i++)cout<<q[i];

return 0;
}


int main()
{
    char a[100];
    gets(a);
    int n=strlen(a);
    int i;
    char b;
    for(i=0;i<n-1;i++){
                       b=a[i]+a[i+1];
                       printf("%c",b);
                       }
    printf("%c",a[n-1]+a[0]);
    return 0;
}


void main()
{
         char *p;
         int i;
         p=(char*)malloc(200*sizeof(char));
         gets(p);
         char *p1;
          p1=(char*)malloc(200*sizeof(char));
         for(i=0;i<strlen(p)-1;i++)
         {

                 *(p1+i)=*(p+i)+*(p+i+1);
                 }
         *(p1+i)=*p+*(p+i);
         for(i=0;i<strlen(p);i++)
         printf("%c",*(p1+i));

}


int main()
{
	char str1[101],str2[101];
	memset(str1,0,101*sizeof(char));
	memset(str2,0,101*sizeof(char));
	gets(str1);
	int len=strlen(str1);
	int i;
	for(i=1;i<=len-1;i++)
	{
		str2[i-1]=str1[i-1]+str1[i];
	}
	str2[len-1]=str1[len-1]+str1[0];
	printf("%s\n",str2);
}


int main()
{
	char string[101];
	char *p1;
	p1=string;

	gets(string);

	char mid[101];
	char *p2;
	p2=mid;
	strcpy(mid,string);

	int i;
	int time=-1;
	for(i=0;*(p1+i)!='\0';i++)
	{
		*(p1+i)=*(p2+i)+*(p2+i+1);
		time++;
	}
	*(p1+time)=*(p2+time)+*(p2+0);

	printf("%s\n",p1);

	return 0;
}


// zhizhen.cpp : Defines the entry point for the console application.
//

int main(int argc, char* argv[])
{
	int i;
	char s[101],b[101];
	gets(s);
	int len=strlen(s);
	for(i=0;i<len-1;i++){
		*(b+i)=*(s+i)+*(s+i+1);
	}
	*(b+len-1)=*(s+len-1)+*(s+0);
	for(i=0;i<len;i++){
		printf("%c",*(b+i));
	}
	return 0;
}


//
//  main.cpp
//  Homework_12_10
//  ???????
//  Created by airjcy on 12/10/12.
//  Copyright (c) 2012 airjcy. All rights reserved.
//

int main(int argc, const char * argv[])
{
    char a[1000];
    char b[1000];
    cin.getline(a, 999);
    int i = 0;
    while (*(a + i + 1) != '\0') {
        *(b + i) = *(a + i) + *(a + i + 1);
        i ++;
    }
    *(b + i) = *(a + i) + *a;
    *(b  + i + 1) = '\0';
    cout << b;

    return 0;
}


int main()
{
	int len,i;
	char a[101],*p = NULL;
	cin.getline(a,101);
	len = strlen(a);
	for (i = 0,p = a; i < len - 1; i++,p++)
		cout << (char) (*p + *(p + 1));
	cout << (char) (a[len - 1] + a[0]) << endl;
return 0;
}


int main()
{
	int len,i;
	char a[100],b[100];
	gets(a);
	len=strlen(a);
	for(i=0;i<len;i++)
	{
		if(i!=len-1)
		{
			b[i]=a[i]+a[i+1];
		}
		else
		{
			b[i]=a[i]+a[0];
		}
	}
	for(i=0;i<len;i++)
	{
		printf("%c",b[i]);
	}

	return 0;
}


int main()
{
	 char *p,*q;
	p=(char *)malloc(sizeof(char)*101);
	q=(char *)malloc(sizeof(char)*101);
	gets(p);
	int i,n=strlen(p);
	for(i=0;i<n;i++)
	{
		if(i==n-1) *(q+i)=*(p+i)+*p;
		else *(q+i)=*(p+i)+*(p+i+1);

	}

//	*(q+n)='\0';
	puts(q);
}


int main()
{
    char a[1000];
    int i,j,k,n,l,f;
    gets(a);
    for(i=0;i<=strlen(a)-2;i++){
                                n=a[i]+a[i+1];
                                printf("%c", n);
                                }
                                n=a[strlen(a)-1]+a[0];
    printf("%c", n);
    return 0;
    }


int main()
{char c[100]={' '};
 int i,j,k,l,n,m;
 gets(c);
 l=strlen(c)-1;
 for (i=0;i<l;i++)
	 printf("%c",c[i]+c[i+1]);
 printf("%c",c[l]+c[0]);
 return 7;
}


int main()
{
    char str[100];
    gets(str);
    int i,n=0;
    char * p=str,* q=&str[1];
    n=strlen(str);
    for(i=0;i<n;i++,p++,q++)
    {
                    if(i!=n-1)
                    printf("%c",* p+* q);
                    if(i==n-1)
                    {
                      q=str;
                    printf("%c",* p+* q);
                    }
     }
     return 0;
     }


/**
 * ??????·
 * ???1000012844
 * ??????????
 **/

int main()
{
	char s1[ 101 ], s[ 101 ];
	cin.getline( s, 101 );
	char *ptr1 = NULL, *ptr2 = NULL, *targetPtr = NULL;
	ptr1 = s;
	ptr2 = s + 1;
	targetPtr = s1;
	int lenth = strlen( s );

	while ( ptr2 != s + lenth )
	{
		*targetPtr++ = *( ptr1++ ) + *( ptr2++ );
	}
	*targetPtr++ = *s + *ptr1;
	*targetPtr = 0;
	cout << s1;
}


int main()
{
	char a[200];
	cin.getline(a, 101);
	int b = strlen(a);
	for (int i = 0; i<b; i++)
		cout << (char)(a[ i] + a[(i + 1) % b]);
}


int main(){
	int n,i,j,k,l;
	char as[110],bs[110];
	gets(as);
	int len=strlen(as);
	for(i=0;i<len-1;i++)
	{
		bs[i]=as[i]+as[i+1];
	}
	bs[len-1]=as[0]+as[len-1];
	bs[len]=0;
	printf("%s",bs);
	return 0;
}


int main()
{
	char s[101],c,*p;
	int len,i,asc1,asc2;
	gets(s);
	len=strlen(s);

	p=&s[0];

	for(i=0;i<len-1;i++)
	{
		asc1=*(p++);
		asc2=*p;
		c=asc1+asc2;
		printf("%c",c);
	}

	asc1=s[len-1];
	asc2=s[0];
	c=asc1+asc2;
	printf("%c",c);

	return 0;
}


void main()
{
	char ori[102],*ptr,qp,*head,*tail;
	int i,n;
	gets(ori);
	n=strlen(ori);
	ptr=&ori[0];
	for(i=0;i<n-1;i++)
	{
		qp=*ptr+*(ptr+1);
		printf("%c",qp);
		ptr++;
	}
	head=&ori[0];
	tail=&ori[n-1];
	qp=*head+*tail;
	printf("%c\n",qp);
}


void friend1(char p[],int n);
int main()
{
	char letter[100];
	int i,j,k;
	gets(letter);
	friend1(letter,strlen(letter));
	puts(letter);
}
void friend1(char p[],int n)
{
	char c;
	int j;
	c=*p;
	for(j=0;j<=n-2;j++)
	{
		*(p+j)=*(p+j)+*(p+j+1);
	}
	*(p+n-1)=*(p+n-1)+c;

}


void main()
{
	char string[100];
	char *p;
	int len;
	int i;
	gets(string);
	len=strlen(string);
	for(p=string;p<string+len-1;p++)
	{
		i=*p+*(p+1);
		printf("%c",i);
	}
	if(p==string+len-1)
	{
		i=*p+*(p-len+1);
		printf("%c",i);
	}
	printf("\n");
}


int main()
{
      char a[101],b[101];
      gets(a);

      int i;
      for(i = 0;i < strlen(a);i++)
      b[i] = a[i] + a[(i+1) % strlen(a)];

      b[strlen(a)] = 0;
      puts(b);
      return 0;
}


char str[105];
int main() {
	cin.getline(str,sizeof(str));
	char b = *str;
	char * p = str;
	while (*(p + 1)) {
		cout << (char) (*p + *(p + 1));
		p++;
	}
	cout << (char) (*p + b);
	return 0;
}


int main()
{
	char s[102],x;
	cin.getline(s,102);
	int l;
	l= strlen(s);
	char *p,*q;
	for(p=s,q=s+1;q<s+l;p++,q++)
	{
		x=*p+*q;
		cout<<x;
	}
	p=s+l-1;q=s;
	x=*p+*q;
	cout<<x;
	return 0;
}


int main(int argc, char* argv[])
{
	char input[101],output[101],*p1;
	int i=0,count=0;

	gets(input);
	p1=input;

	for(p1=input;*(p1+1)!='\0';p1++)
	{
		output[i]=*p1+*(p1+1);
		i++;
		count++;
	}
	if(*(p1+1)=='\0')
		output[count]=*p1+input[0];

	for(i=0;i<=count;i++)
		printf("%c",output[i]);

	return 0;
}


int main()
{
	char ori[101];
	char rel[101];
	gets(ori);
	int i;
	for (i = 0; i < strlen(ori)-1; i++)
	{
		rel[i] = ori[i] + ori[i+1];
		cout << rel[i];
	}
	rel[strlen(ori)-1] = ori[0] + ori[strlen(ori)-1];
	cout << rel[strlen(ori)-1];
	return 0;
}


int main()
{
	char s[150],word[150]={'\0'};
	int k,m,n,i,j;
	char *point;
	gets(s);
	k=strlen(s);
	point=&s[0];
	for(i=0;i<=k-2;i++)
	{word[i]=*(point+i)+(*(point+i+1));}
	word[k-1]=s[0]+s[k-1];
	puts(word);
	return 0;
}


int main()
{
	char str[200];
	char trans[200] = {0};
	int len;
	cin.getline(str, 200);
	len = strlen(str);

	for (int i = 0; i < len - 1;i++)
	{
		trans[i] = str[i] + str[i+1];
	}

	trans[len - 1] = str[len - 1] + str[0];
	cout << trans;
	return 0;
}


int main(int argc, char* argv[])
{
	char sz[101],*p,first;
	p=sz;
	gets(p);
	first=*p;
	for(;*(p+1)!='\0';p++){
		*p=*p+*(p+1);
	}
	*p+=first;
	*(p+1)='\0';
	printf("%s",sz);
	return 0;
}


int main(){
	char in[101];
	int i,n,out;
	gets(in);
	n=strlen(in);
	for(i=0;i+1<n;i++){
		out=(int)(in[i])+(int)(in[i+1]);
		printf("%c",out);
	}
	out=(int)(in[n-1])+(int)(in[0]);
	printf("%c",out);
	return 0;
}


int main()
{int i;
 char a[200],*p,*head;
 p=a;
 head=a;
 gets(a);
 i=strlen(a);

 for(p=a;p<a+i-1;p++){
                            printf("%c",*p+*(p+1));
                            }
 printf("%c",*p+*head);
   scanf("%d",&i);
return 0;
}


int main() {
	char a[105],b[105];
	gets(a);
	int i,temp;
	for(i=0;i<strlen(a)-1;i++)
	{
		temp=*(a+i)+*(a+i+1);
		*(b+i)=temp;
	}
	temp=*(a+0)+a[strlen(a)-1];
	b[strlen(a)-1]=temp;
	for(i=0;i<strlen(a);i++)
	{
		cout<<*(b+i);
	}
	return 0;
}


void process(char *pt,int number)
{
	char *b,head;
	head=*pt;
	for(b=pt;b<pt+number-1;b++)
	{
		*b=*b+*(b+1);
	}
	*(pt+number-1)=*(pt+number-1)+head;
	for(b=pt;b<pt+number;b++)
	{
		printf("%c",*b);
	}
}

int main()
{
	char A[101];
	char *pt;
	int number;
	gets(A);
	number=strlen(A);
	pt=A;
	process(pt,number);
	return 0;
}


int main(int argc, char* argv[])
{
	char zfc[101],*p;
	char str[101],*pn;
	int len;

	gets(zfc);
	len=strlen(zfc);
	for(pn=str,p=zfc;pn<str+len-1;pn++,p++)
		*pn=*p+*(p+1);
	*pn=*p+*zfc;

	for(pn=str;pn<str+len;pn++)
		printf("%c",*pn);

	return 0;
}


//
//  main.cpp
//  ???????
//
//  Created by ? ?? on 12-11-30.
//  Copyright (c) 2012? ? ??. All rights reserved.
//

int main()
{
    char a[1000], b[1000];
    cin.getline(a, 1000);
    int la = strlen(a);
    int i = 0;
    char *p = NULL;
    a[la] = a[0];
    p = a;
    while(i < la)
    {
        char m = *p++, n = *p;
        b[i] = m + n;
        i++;
        cout << b[i - 1];
    }

    return 0;
}


main()
{
      char *give;int num;int i,j,k;int j1,k1;char *head;
      give=(char*)malloc(100*sizeof(char));
      head=(char*)malloc(100*sizeof(char));
      gets(give);
      strcpy(head,give);
      num=strlen(give);
      char *out;
      out=(char*)malloc(100*sizeof(char));
      for(i=0;i<num-1;i++)
      {

                        j=(int)*(give+i)-48;
                        k=(int)*(give+1+i)-48;
                        *(out+i)='a'+j+k-1;
                        printf("%c",*(out+i));
      }
      j1=(int)*(head)-48;
      k1=(int)*(head+num-1)-48;
      *(out+i)='a'+j1+k1-1;
      printf("%c",*(out+i));

      }


int main()
{	char ori[num];
	char change[num];
	int m=0,i=0;
	gets(ori);
	m=strlen(ori);
		for(i=0;i<m;i++)
		{	if(i<m-1)
			{	change[i]=ori[i]+ori[i+1];

			}
		else change[i]=ori[i]+ori[0];

		}
	for(i=0;i<m;i++)
	printf("%c",change[i]);
return 0;
}


int main(){
	char mid,a[100],b[100];
	int i,j,stop,length,dif;
	gets(a);
	length=strlen(a);
	for(i=0;i<length-1;i++){
		b[i]=a[i]+a[i+1];
	}
	b[length-1]=a[0]+a[length-1];
	b[length]=0;
	printf("%s",b);
	scanf("%d",&stop);
	return 0;
}


int main(int argc, char* argv[])
{
	char *p,*q,*p1,*q1,t;
	int i,k;
	p=(char*)malloc(120*sizeof(char));
	gets(p);
	k=strlen(p);
	p1=p;
	t=*p;

	for(i=0;i<k-1;i++)
	{
		*p1=*p1+*(p1+1);
		p1++;
	}
	*p1=t+*p1;

	printf("%s",p);

}


/*
 *  Name:homework.cpp
 *  Created on: 2012-12-12
 *  Author: Meng Li
 *  Function:???????
 */

int main(){                            //???
	char string[101], final[101];      //?????????
	cin.getline (string,101);
	char *init, *result;               //????????????
	result=final;
	int length=strlen(string);
	for (init=string;init<(string+length-1);init++,result++){  //???????????????????????????
		*result=*(init)+*(init+1);
	}
	*result=*init+*(init-length+1);                   //??????????????
	for (int i=0;i<length;i++){
		cout<<final[i];
	}
	return 0;
}


int main()
{
	char a[100];
	int n,i;
	gets(a);
	n=strlen(a);
	for(i=0;i<n;i++)
		printf("%c",a[i]+a[(i+1)%n]);
}


int main()
{
char a[200];
int i,n;
gets(a);
n=strlen(a);
*(a+n)=*a;
for(i=0;i<n;i++)
printf("%c",*(a+i)+*(a+i+1));

return 0;}


/*
 * homework3.cpp
 *
 *  Created on: 2012-12-4
 *      Author: Lixurong
 */

int main()
{
	char a[1000], b;
	cin.getline(a,1000);
    b=*a;
    for( int i=0; i<strlen(a)-1; i++ )
    {
    	int c=*(a+i+1);
    	*(a+i)+=c;
    }
    int c=b, len=strlen(a)-1;
    *(a+len) += c;
    cout << a;
	return 0;
}


int main()
{
	char str[101];
	char *p,t;
	int k;
	gets(str);
	k=strlen(str);
	t=*str;

	for (p=str;p<str+k-1;p++)
		*p=*p+*(p+1);
	*p=*p+t;

	puts(str);
	return 0;
}


void convert(char *s);
char str[1000];
void convert(char *s)
{int i,l;
l=strlen(s);
for(i=0;i<l;i++)
{if(i==l-1)
str[i]=(*(s+l-1))+(*(s+0));
else
str[i]=(*(s+i))+(*(s+i+1));}
str[i+1]='\0';
}
int main()
{char s[1000];
gets(s);
convert(s);
printf("%s",str);}


int main()
{
char *pi;
int i,m;
pi=(char*)malloc(sizeof(char)*101);
gets(pi);
m=strlen(pi);
for (i=0;i<m-1;i++)
{
	printf("%c",*(pi+i)+*(pi+i+1));
}
printf("%c",*(pi+m-1)+*(pi));
free(pi);

return 0;
}


int main()
{
    char qpstr(char a[]);
    char str[101];
    gets(str);
    qpstr(str);
    return 0;
}
char qpstr(char a[])
{
     int i,j,k,len;
     char b[101];
     for(i=0;i<strlen(a)-1;i++)
     b[i]=a[i]+a[i+1];
     b[strlen(a)-1]=a[strlen(a)-1]+a[0];
     b[strlen(a)]='\0';
     puts(b);
}


int main()
{
    char str[101];
    char friend[101];
    char *p = str;
    char *q = friend;
    gets(str);
    while (p < str + strlen(str) - 1) {
        *q++ = *p + *(p + 1);
        p++;
    }
    *q = *p + *str;
    *(friend + strlen(str)) = 0;
    puts(friend);
    return 0;
}


int main()
{
	int i,j,len;
	char a[101],*pa;
	gets(a);
	pa=&a[0];
	len=strlen(a);
	i=0;
	for(i=0;i<len-1;i++)
	{
		printf("%c",*(pa+i)+*(pa+i+1));
	}
	printf("%c",*(pa)+*(pa+len-1));
	return 0;
}


int main()
{
    char str[105];
    memset (str, 0, sizeof(str));
    cin.getline(str, 105);
    str[strlen(str)] = str[0];
    for (int i = 0; i < strlen(str) - 1; i++)
        cout <<(char)(str[i] + str[i+1]);
    return 0;
}


int main()
{
    char string[200],string1[200];
    gets(string);
    int n,i;
    n=strlen(string);
    for(i=0;i<n;i++)
    {
                    if(i!=n-1)
                    {
                      string1[i]=string[i]+string[i+1];
                    }
                    if(i==n-1)
                    {
                              string1[i]=string[i]+string[0];
                              }
    }
    for(i=0;i<n;i++)
    {
                    printf("%c", string1[i]);
    }

    return 0;
}


int main()
{
	char str[101],fri[101];
	int i;
	gets(str);

	for(i=0;i<L-1;i++)
	{
		printf("%c",str[i]+str[i+1]);
	}
	printf("%c\n",str[i]+str[0]);
	return 0;
}


int main(int argc, char* argv[])
{
	char ch[101], *p ,a[101];
	int len,i=0;
	gets(ch);
	p=ch;
	len=strlen(ch);
	for(p=ch;p<ch+len;p++)
	{
		a[i]=*p+*(p+1);
		if(p==ch+len-1)
		a[i]=*(p)+ch[0];
		printf("%c",a[i]);
		i++;
	}printf("\n");
	return 0;
}


int main()
{
	char str[101], *p_str, temp;
	cin.getline(str,101);
	temp = str[0];
	p_str = str;
	while (*(p_str + 1)!= '\0')
	{
		*p_str = *p_str + *(p_str + 1);
		p_str++;
	}
	*p_str = *p_str + temp;
	cout << str;
	return 0;
}


void main()
{
	int len,i;
	char s[1000];
	gets(s);
	len=strlen(s);
	for (i=0;i<len-1;i++)
      printf("%c",(int)(s[i])+(int)(s[i+1]));
	printf("%c\n",(int)(s[0])+(int)(s[len-1]));
}


/**
* @file homework.cpp
* @author ??
* @date 2010?12?15
* @description
* ??????:?????????
*/
int main()
{
	int i, length;
	char zifu[101];
	cin.getline(zifu,101,'\n');
	length = strlen(zifu);
	for (i=0;i<length;i++)
	{
		if (i==length-1)
			cout << (char)(zifu[i] + zifu[0]);
		else
			cout << (char)(zifu[i] + zifu[i+1]);
	}
	return 0;
}


void main()
{
	char *p;
	int i,j,k,l,n,m;
	p=(char*)malloc(101*sizeof(char));
	gets(p);
	l=strlen(p);
	*(p+l)=*(p);
	for(i=0;i<l;i++) *(p+i)+=*(p+i+1);
	*(p+l)='\0';
	puts(p);
}


void main()
{
	char str[101], fri[101]={'\0'}, *pca, *pcb;
	int n, i;
	gets(str);
	n=strlen(str);
	if(n>=2 && n<=100)
	{
		for(pca=str, pcb=str+1, i=0; pca<(str+n-1); pca++, pcb++, i++)
			fri[i]=*pca + *pcb;
		fri[n-1]=str[0]+str[n-1];
		printf("%s\n",fri);
	}
}


void friends(char c[100],int l);
void main()
{
	char c[100];
	gets(c);
	int l=strlen(c);
	friends(c,l);
}

void friends(char c[100],int l)
{
	int i;
	char p[100];
	for(i=0;i<l-1;i++)
		p[i]=c[i]+c[i+1];
	p[l-1]=c[l-1]+c[0];
	p[l]='\0';
	puts(p);
}


int main(int argc, char* argv[])
{	char s[1000];
	char * p, * a;
	int i;
	gets(s);
	a=s;
	for(p=s; p<s+strlen(s)-1; p++){
		printf("%c",*p + *(p+1));
	}
	printf("%c",*p + *a);
	return 0;
}


int main(){
	char s[100];
	char a;
	gets(s);
	int n,i,j;
	n=strlen(s);
	for(i=0;i<(n-1);i++){
		j=s[i]+s[i+1];
        a=j;
		printf("%c",a);
	}
	j=s[n-1]+s[0];
	a=j;
	printf("%c",a);

	return 0;
}


int main()
{
	char sentence[101], change[101];
	int i;
	char *point = NULL;
	memset(change, '\0', sizeof(change));
	cin.getline(sentence, 101);
	point = sentence;
	for (i = 0; i < strlen(sentence) - 1; i++)
	{
		change[i] = *(point + i) + *(point + i + 1);
	}
	change[strlen(sentence) - 1] = *point + *(point + strlen(sentence) - 1);
	cout << change << endl;
	return 0;
}


int main() {
	char s[101];
	cin.getline(s,101);
	char *p=s,*q=NULL;
	int len=strlen(s);
	char x=s[0];
	q=s+len-1;
	for(p=s;p<s+len-1;p++)
		*p=(char)((int)*p+(int)*(p+1));
	for(p=s;p<s+len-1;p++)
		cout<<*p;
	cout<<(char)((int)(*q)+(int)(x));

	return 0;
}


int main()
{
    int n,i,j;
    char a[105],b[105];
    gets(a);
    for(i=0;i<strlen(a);i++)
    {
        if(i==strlen(a)-1)
        {
            b[i]=a[i]+a[0];
        }
        else
            b[i]=a[i]+a[i+1];
    }
    b[strlen(a)]='\0';
        puts(b);

    return 0;
}


void main()
{
	char str[200],*p,wd;
	int i,n;
	gets(str);
	p=str;
	n=strlen(p);
	for(i=0;i<n;i++)
	{if(i!=n-1){wd=*(p+i)+*(p+i+1);
	printf("%c",wd);}
	else {wd=*(p+0)+*(p+i);
	printf("%c",wd);}}

}


int main()
{
	char *org;
	org=(char*)malloc(100*sizeof(char));
	gets(org);
	int i,n,d;
	n=strlen(org);
	for(i=0;i<n-1;i++)
	{

		d=*(org+i)+*(org+i+1);
		printf("%c",d);
	}
	d=*(org+i)+*org;
	printf("%c\n",d);
}


void main()
{
 int i,j,n,k,m;
 char *p,*q,l;
 p=(char *)malloc(100*sizeof(char));
 q=(char *)malloc(100*sizeof(char));
 gets(p);
 m=strlen(p);
 for(i=0,j=0;i<m-1;i++,j++)
    {
     *(q+j)=*(p+i)+*(p+i+1);
     printf("%c",*(q+j));
     }
 l=*p+*(p+m-1);
 printf("%c",l);
}


int main()
{
	int i,size;
	char zfc[100];
	char qp;
	gets(zfc);
	size=strlen(zfc);
	for(i=0;i<size;i++)
	{
		if(i==size-1)
		{
			qp=zfc[size-1]+zfc[0];
			printf("%c",qp);
		}else
		{
			qp=zfc[i]+zfc[i+1];
			printf("%c",qp);
		}
	}
	return 0;
}


int main()
{
	char ch[101],str[101];
	char *p;
	int i,j,k;
	gets(ch);
	k=strlen(ch);
	p=ch;
	for (i=0;i<k-1;i++)
	{
		str[i]=*p+*(p+1);
		p++;
	}
	str[k-1]=*p+ch[0];
    for (i=0;i<k;i++)
		printf("%c",str[i]);
	return 0;
}


int main()
{
    char str[150], x;
    cin.getline(str, 150);
    int len = strlen(str);
    char *p = str;
    for (; p < &str[len-1]; p++)
    {
        x = *p + *(p + 1);
        cout << x;
    }
    x = str[len-1] + str[0];
    cout << x << endl;
    return 0;
}


int main()
{
	char str[101] , temp;
	int i;

	cin.getline(str , 101);

	temp = str[0];
	for(i = 0; str[i + 1] != 0; i++)
		str[i] += str[i + 1];

	str[i] += temp;

	cout << str << endl;
	return 0;
}


int main() {
	char a[105],b[105];
	gets(a);
	int i,temp;
	for(i=0;i<strlen(a)-1;i++)
	{
		temp=a[i]+a[i+1];
		b[i]=temp;
	}
	temp=a[0]+a[strlen(a)-1];
	b[strlen(a)-1]=temp;
	for(i=0;i<strlen(a);i++)
	{
		cout<<b[i];
	}
	return 0;
}


int main()
{
	char A[105]={'\0'};
	int len;
	int i;
	char *pt,*pt1,temp;
	pt=A;
	gets(pt);
	len=strlen(A);
	pt1=&temp;
	*pt1=*pt;
	for(i=0;i<len-1;i++)
	{
		*pt= *pt + *(pt+1);
		pt++;
	}
	*pt= *pt + *pt1 ;
	pt=A;
	puts(pt);
	return 0;
}


int main()
{
	int i,length;
	char sz1[101],sz2[101],*character,*family;
	character=sz1;
	gets(character);
	family=sz2;
	for(i=0;*(character+i+1)!='\0';i++)
	{
		*family=*(character+i)+*(character+i+1);
		family++;
	}
	*family++=*character+*(character+i);
	*family='\0';
	family=sz2;
	if(*family!='\0')
		printf("%s",family);
	return 0;
}


int main()
{
	char zfc[100],qin[100];
	int n,ascii[100],i,a;
	gets(zfc);
	n=strlen(zfc);

	for(i=0;i<n;i++)
	{
        ascii[i]=zfc[i];
	}

	a=ascii[0]+ascii[n-1];

	for(i=0;i<n-1;i++)
	{
		ascii[i]=ascii[i]+ascii[i+1];
	}

	ascii[n-1]=a;

	for(i=0;i<n;i++)
	{
		qin[i]=ascii[i];
	}

	for(i=0;i<n;i++)
	{
		printf("%c",qin[i]);
	}
	return 0;
}


int main()
{
	char a[120];
	cin.getline(a,120);
	int j = strlen(a);
	char b[120];
	int k = 0;
	char *p = a;
	for(  ; p < a + j ; p++)
	{
		if( p == a + j - 1)
			b[k++]= (int) *p +  (int)a[0] ;
 		b[k++] = (int)*p + (int)*(p+1) ;
	}
	for( int i = 0 ; i < k-1 ; i++)
	{
		cout<<b[i];
	}
	cout<<endl;

	return 0;
}


int main()
{
	char str[1000],str1[1000];
	int a[122],i,l;
	gets(str);
	l=strlen(str);
	for (i=0;i<l-1;i++)
		str1[i]=str[i]+str[i+1];
	str1[l-1]=str[l-1]+str[0];
	for (i=0;i<l;i++)
		printf("%c",str1[i]);
	return 0;
}


int main()
{
	char str[101];
	cin.getline(str, 101);
	char *p = str;
	char ch = str[0];
	while (p < str + strlen(str) - 1)
	{
		* p = * p + * (p+1);
		p ++;
	}
	* p += ch;
	* ++p = '\0';
	for (p = str; p < str + strlen(str); p ++)
		cout << * p ;
	return 0;
}


int main()
{

	char a[101] ;
	char b[101] ;
	cin.getline(a,101) ;
	int length = strlen(a) ;
	for(int i = 0 ; i<(length - 1) ; i++)
	{
		b[i] = a[i] + a[i+1] ;
		cout<<b[i] ;
	}
	cout<<(char)(a[length-1]+a[0]) ;
	return 0 ;
}


int main()
{
	char words1[300],k;
	int i,n=0;
	gets(words1);
	k=words1[0];
	for(i=0;words1[i];i++)
	{
		n++;
	}
	for(i=0;i<n-1;i++)
	{
		words1[i]=words1[i]+words1[i+1];
	}
	words1[n-1]=words1[n-1]+k;
	for(i=0;i<n;i++)
	{
		printf("%c",words1[i]);
	}
	return 0;
}


int main()
{
	char a[101], *pa = a, b[101], *pb = b;
	cin.getline(a, sizeof(a));
	for (pa = a; pa < a + strlen(a) - 1; pa++) *pb++ = *pa + *(pa + 1);
	*pb++ = *pa + *a;
	*pb = '\0';
	cout << b << endl;
	return 0;
}


int main(){
    char s[110],*p;
    int len;
    gets(s);
    len=strlen(s);
    for(p=s;p<s+len;p++){
        if(p==s-1+len)
            printf("%c",(*p)+s[0]);
        else
            printf("%c",(*p)+*(p+1));
    }
    return 0;
}


void main()
{
	char str[101], fri[101], *pca, *pcb;
	int n, i;
	gets(str);
	n=strlen(str);
	for(pca=fri; pca<=(fri+n); pca++)
		*pca='\0';
	if(n>=2 && n<=100)
	{
		for(pca=str, pcb=str+1, i=0; pca<(str+n-1); pca++, pcb++, i++)
			fri[i]=*pca + *pcb;
		fri[n-1]=str[0]+str[n-1];
		printf("%s\n",fri);
	}
}


int main ()
{
	char str[10000];
	cin.get(str, 10000);
	int len = strlen(str);
	char temp = str[0];
	int i;
	for (i = 0; i < len - 1; i++)
	{
		str[i] = str[i] + str[i + 1];
	}
	str[i] = temp + str[i];
	str[i + 1] = '\0';
	cout << str << endl;
	return 0;
}


int main()
{
    char data[101];
    char output[101];
    gets(data);
    int len = strlen(data);
    int i;

    for(i = 0; i <= len - 2; i++)
          *(output + i) = *(data + i) + *(data + i + 1);

    *(output + len - 1) = *(data + len - 1) + *data;
    *(output + len) = '\0';
    puts(output);

    return 0;
}


/*
 * theoutputstring.cpp
 *
 *  Created on: 2012-12-17
 *      Author: ???
 */
int main() {
	char a[101], *p = a, b[100], *q = b;
	int n;
	cin.getline(a,101);
	n = strlen(a);
	while (p < a + n - 1) {
		*q = *p + *(p + 1);
		p++;
		q++;
	}

		*q = *p + *a;
	for (q = b; q < b + n; q++)
		cout << *q;
	return 0;
}


int main()
{
	char *p1,*p2,a[100];
	int len,i=0;
	gets(a);
	len=strlen(a);
	p1=a;
	p2=a+1;
	do{
         printf("%c",*p1+*p2);
		 p1=p2;
		 if(p2==a+len-1){
			 p2=a;
		 }
		 else p2++;
		 i++;
	}while(i<len);
	return 0;
}


int main(int argc, char *argv[])
{
  char a[1000];
  int i;
  gets(a);
  int b=a[0];
  for (i=0;i<=strlen(a)-2;i++)
  {
      a[i]=a[i]+a[i+1];
  }
  a[strlen(a)-1]=a[strlen(a)-1]+b;
  for (i=0;i<=strlen(a)-1;i++)
      printf("%c",a[i]);
  return 0;
}


int main()
{
    char str[100];
	int i;
	gets(str);
	int n;
	n=strlen(str);
    for(i=0;i<(n-1);i++)
	{
		int p,q;
		p=(int)str[i];
		q=(int)str[i+1];
		printf("%c",p+q);
	}
	int p,q;
	p=(int)str[0];
	q=(int)str[n-1];
	printf("%c",p+q);
	return 0;
}


int main()
{
	char str[201];
	gets(str);
	char *p;
	char s[200];
	int i;
	int len=strlen(str);
	p=str;
	for (i=0;i<len-1;i++)
	{
		s[i]=*p+*(p+1);
		p++;
	}
	if (p==&str[len-1])
	{
		s[len-1]=*p+(str[0]);
	}
	p=s;
	for (i=0;i<len;i++,p++)
	{
		printf("%c",*p);
	}
	return 0;
}


int main()
{
	char *p;
	char c;
	int i;
	p=(char *)malloc(100*sizeof(char));
	gets(p);
	c=*p;
	for (i=0;i<(strlen(p)-1);i++)
		*(p+i)=*(p+i)+*(p+i+1);
	*(p+strlen(p)-1)=*(p+strlen(p)-1)+c;
	for (i=0;i<strlen(p);i++)
		printf("%c",*(p+i));
	return 0;
}


int main(){
    char s[102],w[102];
    int i,ls;
    gets(s);

    ls=strlen(s);
    memset(w,0,sizeof(w));

    for(i=0;i<ls;i++){
                      if(i<ls-1){
                                  w[i]=s[i]+s[i+1];
                                  }
                      else if(i==ls-1){
                           w[ls-1]=s[ls-1]+s[0];
                           }
                      }

    puts(w);
    scanf("%d",&i);
    return 0;

}


int main(int argc, char* argv[])
{
	char sz[101],fri[101];
	int i;
	gets(sz);
	for(i=0;sz[i+1]!='\0';i++){
		fri[i]=sz[i]+sz[i+1];
	}
	fri[i]=sz[i]+sz[0];
	fri[i+1]='\0';
	puts(fri);
	return 0;
}


int main()
{
	char cha[500];
	gets(cha);
	int i=0,b;
	for(i=0;cha[i]!='\0';i++)
	{
		if(cha[i+1]=='\0')
		{
			b=(int)cha[i]+(int)cha[0];
			printf("%c",b);
		}
		else
		{
			b=(int)cha[i]+(int)cha[i+1];
			printf("%c",b);
		}
	}
	return 0;
}


int main()
{
	char ori[101];
	gets(ori);
	int i;
	for(i=0;i<strlen(ori)-1;i++)
	{
		printf("%c",ori[i]+ori[i+1]);
	}
	printf("%c\n",ori[i]+ori[0]);
	return 0;
}


int main()
{
    int i, len;
    char str[102];

    gets(str);

    len=strlen(str);
    *(str+len)=*str;

    for(i=0; i<len; i++)
    {
        *(str+i)=*(str+i)+*(str+i+1);
    }

    for(i=0; i<len; i++)
    {
        printf("%c", *(str+i));
    }

    return 0;
}


int main()
{
	char a[102]={0};
	char temp;
	int l,i=1;
	char *p;
	gets(a);
	p=a;
	l=strlen(a);
	temp=*p;
	for(i=0;i<l-1;i++,p++)
		*p=*p+*(p+1);
	*p=*p+temp;
	p=a;
	for(i=0;i<l;i++)
		printf("%c",*(p++));
	return 0;
}


int main()
{
    char str[1000],*p,*p1=str;
    int m,i;
    gets(str);
    m=strlen(str)-1;
    for(i=0;i<strlen(str)-1;i++)
    {
      p=&str[i];
      printf("%c",*p+*(p+1));
    }
    p=&str[m];
    printf("%c",*p+*p1);
    return 0;
}


/*
 * zhizheng.cpp
?? - ???????
 *  Created on: 2012-12-12
 *      Author: ???
 */
char str1[101],str2[101],*p=NULL,*q=NULL;
int len1;
int main(){
	cin.getline(str1,101);
	len1=strlen(str1);
	for(p=str1,q=str2;p<str1+len1-1;p++,q++)
	{
		*q=*p+*(p+1);
	}
	*q=*p+*(p-len1+1);
	cout<<str2<<endl;
	return 0;
}


void main()
{
	char str[200];
	char  str1[200];
	char *p,*r;
	char *q;
	int m,i;
	gets(str);
	p=str;
	m=strlen(str);
	q=str1;
	for(i=0;i<m-1;i++)
	{
       r=p+1;
	   *q=*p+*r;
	   p++;
	   q++;
	  }
*q=*p+*str;
q=str1;
for(i=0;i<m;i++,q++)
printf("%c",*q);
}


int main()
{
    int len;
    char str[200],*p;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    gets(str);
    len = strlen(str);
    for (p = str; *(p+1); p++)
        printf("%c", *p + *(p+1));
    printf("%c\n", *p + *str);
    return 0;
}


int main()
{
	char a[200];
	int n,i,temp;
	gets(a);
	n=strlen(a);
	for(i=0;i<n-1;i++)
	{
		temp=a[i]+a[i+1];
		printf("%c",temp);
	}
	temp=a[n-1]+a[0];
	printf("%c",temp);
}


void main()
{
	int len;
	char *str,*p,*q;
	str=(char *)calloc(150,sizeof(int));
	gets(str);
	len=strlen(str);
	for(p=str;p-str<len-1;p++)
		printf("%c",*p+*(p+1));
	printf("%c\n",*p+*str);
}


int MyCompare(const void* a,const void* b)
{
	return (*(int *)b-*(int *)a);
}
int main()
{
	int i,j,p,q,n;
	int result;
	int speed1[1000],speed2[1000];

	while(cin>>n)
	{
		if(n==0) break;
		result=0;
		for(i=0;i<n;i++)
			cin>>speed1[i];
		for(i=0;i<n;i++)
			cin>>speed2[i];
		qsort(speed1,n,sizeof(int),MyCompare);
		qsort(speed2,n,sizeof(int),MyCompare);
		/*for(i=0;i<n;i++)
			cout<<speed1[i];
		for(i=0;i<n;i++)
			cout<<speed2[i];*/
		i=p=0;
		j=q=n-1;
		while(i<=j)
		{
			if(speed1[i]>speed2[p])
			{
				result += 200;
				i++;
				p++;
			}
			else if(speed1[j]>speed2[q])
			{
				result += 200;
				j--;
				q--;
			}
			else if(speed1[j]==speed2[p])
			{
				j--;
				p++;
			}
			else
			{
				result -= 200;
				j--;
				p++;
			}
		}
		cout<<result<<endl;
	}
	return 0;
}


int compare(const void*elem1,const void*elem2)
{
    return(*(int*)elem1-*(int*)elem2);
}
main()
{
    int n,max,sum,i,j;
    int a[2000],b[1000];
    for(;;)
    {
        sum=0;
        scanf("%d",&n);
        if(n==0)
        break;
        for(i=0;i<n;i++)
        {
            scanf("%d",&a[i]);
        }
        for(i=0;i<n;i++)
        scanf("%d",&b[i]);
        qsort(a,n,sizeof(int),compare);
        qsort(b,n,sizeof(int),compare);
        for(i=0;i<n;i++)
        a[i+n]=a[i];
        max=-n;
        for(i=0;i<n;i++)
        {
            sum=0;
            for(j=0;j<n;j++)
            {
                if(a[i+j]<b[j])
                sum--;
                else if(a[i+j]>b[j])
                sum++;
            }
            if(sum>=max)
            max=sum;
        }
        max=max*200;
        printf("%d\n",max);
    }
}


int dp[N][N];
int a[N],b[N];
int n;

void Qsort(int a[],int i,int j)
{
    int i1=i,j1=j,tmp=a[i];
    while(i<j)
    {
        while(i<j && a[j]<tmp)  j--;
        if(i<j) a[i++]=a[j];
        while(i<j && a[i]>tmp)  i++;
        if(i<j) a[j--]=a[i];
    }
    a[i]=tmp;
    if(i1<i-1)  Qsort(a,i1,i-1);
    if(j+1<j1)  Qsort(a,j+1,j1);
}

void init()
{
    int i,j;
    for(i=0;i<n;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    Qsort(a,0,n-1);
    Qsort(b,0,n-1);
}

int max(int x,int y)
{
    return x>y?x:y;
}

int judge(int x,int y)
{
    if(x==y)    return 0;
    if(x>y) return 1;
    return -1;
}

void solve()
{
    int i,j;
    for(i=0;i<n;i++)
    {
        for(j=0;i+j<n;j++)
        {
            if(i==0)
            {
                dp[j][i+j]=judge(b[j],a[n-1]);
            }
            else
            {
                dp[j][i+j]=max(dp[j+1][i+j]+judge(b[j],a[n-1-i]),
                               dp[j][i+j-1]+judge(b[i+j],a[n-1-i]));
            }
        }
    }
}

int main()
{
    while(scanf("%d",&n))
    {
        if(!n)  break;
        init();
        solve();
        printf("%d\n",dp[0][n-1]*200);
    }
    return 0;
}


int bijiao(const void *x,const void *y)
{return *(int*)y-*(int*)x;
}
int main()
{
	while(1)
	{
		int n,i,j=0,k,temp=0,sum=0,tmax=0,tmin,qmax=0,qmin;
		scanf("%d",&n);
		if(n==0)
		return 0;
		else
		{  int a[1001]={0},b[1001]={0};
		   for(i=0;i<n;i++)
		   scanf("%d",&a[i]);
		   for(i=0;i<n;i++)
		   scanf("%d",&b[i]);
		   qsort(a,n,sizeof(a[0]),bijiao);
		   qsort(b,n,sizeof(b[0]),bijiao);
		   tmin=n-1;qmin=n-1;
		   for(i=0;i<n;i++)
		   {
			if(a[tmax]>b[qmax])
			{
				temp++;
				tmax++;
				qmax++;
			}
			else
			{
				if(a[tmax]<b[qmax])
				{
					temp--;
					tmin--;
					qmax++;
				}
				else
				{
					if(a[tmin]>b[qmin])
					{
						temp++;
						tmin--;
						qmin--;
					}
					else
					{
						if(a[tmin]<b[qmin])
						{
							temp--;tmin--;qmax++;
						}
						else
						{
							if(a[tmin]<b[qmax])
							{
								temp--;tmin--;qmax++;
							}
							else
							if(a[tmin]==b[qmax])
							break;
						}
					}
				}
			}
		   }
			printf("%d\n",temp*200);
		}
	}
}


int comp(const void* p1,const void* p2)
{
	int* p11=(int*)p1;
	int* p22=(int*)p2;
	return *p11-*p22;
}

int main()
{
	int n;
	int hq[1010],ht[1010];
	while(cin>>n && n!=0)
	{
		for(int i=0;i!=n;++i)
			cin>>ht[i];
		for(int i=0;i!=n;++i)
			cin>>hq[i];
		qsort(ht,n,sizeof(int),comp);
		qsort(hq,n,sizeof(int),comp);
		int it=0,iq=0,jt=n-1,jq=n-1;
		int result=0;
		for(int i=0;i!=n;++i)
		{
			if(ht[jt]>hq[jq])
			{
				--jt,--jq;
				result+=200;
			}
			else if(ht[it]>hq[iq])
			{
				++it,++iq;
				result+=200;
			}
			else
			{
				if(ht[it]<hq[jq])
					result-=200;
				++it,--jq;
			}
		}
	cout<<result<<endl;

	}
	return 0;
}


int myCompare(const void *int_a, const void *int_b)
{
	return *(int*)int_b - *(int*)int_a;
}

int main()
{
	int n, i;
	int *QiWang;
	int *TianJi;
	int *QFast;
	int *TFast;
	int *QSlow;
	int *TSlow;
	int countWin;

	while(1){

		scanf("%d", &n);
		if(n==0)
			break;
		if(((QiWang=(int*)malloc(n*sizeof(int)))==NULL)
			||((TianJi=(int*)malloc(n*sizeof(int)))==NULL)){
			printf("Error: memory out! (1)/n");
			exit(-1);
		}
		for(i=0; i<n; i++){
			scanf("%d", &TianJi[i]);
		}
		for(i=0; i<n; i++){
			scanf("%d", &QiWang[i]);
		}
		qsort(TianJi, n, sizeof(int), myCompare);
		qsort(QiWang, n, sizeof(int), myCompare);

		TFast = TianJi;
		QFast = QiWang;
		TSlow = TianJi + n - 1;
		QSlow = QiWang + n - 1;

		countWin = 0;
		while(1){
			if(*TSlow<*QSlow){
				countWin --;
				TSlow --;
				QFast ++;
			}else if(*TSlow>*QSlow){
				countWin ++;
				TSlow --;
				QSlow --;
			}else{
				if(TFast!=TSlow){
					if(*TFast<*QFast){
						countWin --;
						QFast ++;
						TSlow --;
					}else if(*TFast==*QFast){
						if(*QFast>*TSlow)
							countWin --;
						QFast ++;
						TSlow --;
					}else{
						countWin ++;
						QFast ++;
						TFast ++;
					}
				}else{
					break;
				}
			}
			if(TFast>TSlow)
				break;
		}
		printf("%d\n", 200*countWin);
		free(TianJi);
		free(QiWang);
	}

	return 0;
}


void insertsort(int* array,int left,int right){
     int i,j,temp;
     for(i = left + 1; i <= right; i++){
           temp = array[i];
           for(j = i - 1; j >= left; j--){
                 if(array[j] > temp){
                             array[j + 1] = array[j];
                 }
                 else{
                      break;
                 }
           }
           array[j + 1] = temp;
     }
}
void merge(int* array,int* temp,int left,int right,int middle){
     int i,j,k,index1,index2;
     for(i = left; i <= middle; i++){
           temp[i] = array[i];
     }
     for(j = 1; j <= right - middle; j++){
           temp[right - j + 1] = array[j + middle];
     }
     for(index1 = left,index2 = right, k = left; k <= right; k++){
                if(temp[index1] <= temp[index2]){
                     array[k] = temp[index1++];
                }
                else{
                     array[k] = temp[index2--];
                }
     }
}
void mergesort(int* array,int* temp,int left,int right){
     if(right - left > 16){
             int middle = (left + right) / 2;
             mergesort(array,temp,left,middle);
             mergesort(array,temp,middle + 1,right);
             merge(array,temp,left,right,middle);
     }
     else{
          insertsort(array,left,right);
     }
}
int main(){
    int n;
    scanf("%d",&n);
    if(n == 0){return 0;}
    int horse_q[1005];      //????
    int horse_t[1005];     //????
    int i;
    for(i = 0; i < n; i++){
            scanf("%d",&horse_t[i]);
    }
    for(i = 0; i < n; i++){
            scanf("%d",&horse_q[i]);
    }
    int temp[1005];
    mergesort(horse_t,temp,0,n - 1);
    mergesort(horse_q,temp,0,n - 1);
    int t_head = n - 1;        //??????????
    int t_last = 0;            //??????????
    int q_head = n - 1;           //??????????
    int q_last = 0;       //??????????
    int ans = 0;              //??
    while(q_head >= q_last){     //??????????
         if(horse_t[t_head] > horse_q[q_head]){
                       ans += 200;
                       t_head--;
                       q_head--;
         }
         else if(horse_t[t_head] < horse_q[q_head]){
              ans -= 200;
              t_last++;
              q_head--;
         }
         else{
              if(horse_t[t_last] > horse_q[q_last]){
                        ans += 200;
                        t_last++;
                        q_last++;
              }
              else{
                   if(horse_t[t_last] < horse_q[q_head]){
                                      ans -= 200;
                   }
                   t_last++;
                   q_head--;
              }
         }
    }
    printf("%d\n",ans);
    main();
}


int min(int a[],int n)
{
	int min=a[1],i;
	for(i=0;i<n;i++)
	{
		if(min>a[i])
		{
			min=a[i];
		}
	}
	return min;
}
void main()
{
	int T[1100],Q[1100],n=1,i,k,e,s,money=0,first,endT,endQ;
	while(n!=0)
	{
		scanf("%d",&n);
		first=0,endT=n-1,endQ=n-1;
		if(n==0)
			break;
		for(i=0;i<n;i++)
			scanf("%d",&T[i]);
		for(i=0;i<n;i++)
			scanf("%d",&Q[i]);
		for(k=1;k<n;k++)
		{
			for(i=0;i<n-k;i++)
			{
				if(T[i]<T[i+1])
				{
					e=T[i];
					T[i]=T[i+1];
					T[i+1]=e;
				}
				if(	Q[i]<Q[i+1])
				{
					e=Q[i];
					Q[i]=Q[i+1];
					Q[i+1]=e;
				}
			}
		}
		for(i=0;i<n;i++)
		{
			if(T[first]>Q[i])
			{
				first++;
				money+=200;
			}
			else if(T[first]<Q[i])
			{
				endT--;
				money-=200;
			}
			else if(T[first]==Q[i])
			{
				for(k=endT,s=endQ;k>=first;k--,s--)
				{
					if(T[k]>Q[s])
					{
						money+=200;
						endT--;
						endQ--;
					}
					else
					{
						if(T[k]<Q[i])
						money-=200;
						endT=k-1;
						endQ=s;
						break;
					}
				}
			}
			if(first>endT)
				break;
		}
		printf("%d\n",money);
		money=0;
	}
}


void exchange(int *a,int *b)
{
	if(*a>*b)
	{
		*a=*a+*b;
		*b=*a-*b;
		*a=*a-*b;
	}
}
void sort(int*p,int n)
{
	int i,j;
	for(i=0;i<n-1;i++)
	for(j=0;j<n-1-i;j++)
	exchange(p+j,p+j+1);
}
int race(int*t,int*q,int n)
{
	int tj=0,qw=0,count=0;
	for(;;)
	{
		if(n==0)	break;
		if(*(t+tj)>*(q+qw))
		{	tj++;qw++;count++;n--;	}
		else if(*(t+tj+n-1)>*(q+qw+n-1))
		{	count++;n--;	}
		else
		{
			if(*(t+tj)<*(q+qw+n-1))count--;
			tj++;n--;
		}
	}
	return count;
}
int main()
{
	int n,t[1000],q[1000],i;
	for(;;)
	{
	scanf("%d",&n);
	if(n==0)break;
	for(i=0;i<n;i++)scanf("%d",&t[i]);
	for(i=0;i<n;i++)scanf("%d",&q[i]);
	sort(t,n);
	sort(q,n);
	printf("%d\n",200*race(t,q,n));
	}
	return 0;
}


int compare(const void*a,const void*b)
{
	return (*(int*)b)-(*(int*)a);
}
int main()
{
	int n=0,i=0,tianji[1000]={0},qiwang[1000]={0};
	while(cin>>n)
	{
		if(n==0)
			break;
		for(i=0;i<n;i++)
			cin>>tianji[i];
		for(i=0;i<n;i++)
			cin>>qiwang[i];
		qsort(tianji,n,sizeof(int),compare);
		qsort(qiwang,n,sizeof(int),compare);
		int head1=0,tail1=n-1,head2=0,tail2=n-1,money=0;
		while(head1<=tail1)
		{
			if(tianji[tail1]>qiwang[tail2])
			{
				money+=200;
				tail1--;
				tail2--;
			}
			else if(tianji[tail1]<qiwang[tail2])
			{
				money-=200;
				tail1--;
				head2++;
			}
			else
			{
				if(tianji[head1]>qiwang[head2])
				{
					money+=200;
					head1++;
					head2++;
				}
				else if(tianji[head1]<qiwang[head2])
				{
					money-=200;
					tail1--;
					head2++;
				}
				else
				{
					if(tianji[tail1]<qiwang[head2])
						money-=200;
					tail1--;
					head2++;
				}
			}
		}
		cout<<money<<endl;
	}
	return 0;
}


void main()
{
	int num[100],speed_tian[100][1000],speed_qi[100][1000],money[100],win,lose,i,j,k,l,end_qi,x,start_qi,start_tian,mid;
	for(i=0;;i++)
	{
		scanf("%d",&num[i]);
		if (num[i]==0) break;
		else
		{
			for(j=0;j<=num[i]-1;j++)	scanf("%d",&speed_tian[i][j]);
			for(j=0;j<=num[i]-1;j++)	scanf("%d",&speed_qi[i][j]);
		}
	}//??????
	for(j=0;j<=i-1;j++)
	{
		for (k=0;k<=num[j]-1;k++)
			for (l=0;l<num[j]-1-k;l++)
				if(speed_tian[j][l]<speed_tian[j][l+1])
				{
					mid=speed_tian[j][l];
					speed_tian[j][l]=speed_tian[j][l+1];
					speed_tian[j][l+1]=mid;
				}
	}//????????
	for(j=0;j<=i-1;j++)
	{
		for (k=0;k<=num[j]-1;k++)
			for (l=0;l<num[j]-1-k;l++)
				if(speed_qi[j][l]<speed_qi[j][l+1])
				{
					mid=speed_qi[j][l];
					speed_qi[j][l]=speed_qi[j][l+1];
					speed_qi[j][l+1]=mid;
				}
	}//????????
	for(j=0;j<=i-1;j++)//??????
	{
		start_qi=0;
		start_tian=0;
		end_qi=num[j]-1;
		win=0;
		lose=0;
		x=num[j]-1;
		while(x>=start_tian)
		{
			if (speed_tian[j][x]>speed_qi[j][end_qi])
			{
				win++;
				end_qi--;
			}
			else if(speed_tian[j][x]<speed_qi[j][end_qi])
			{
				lose++;
				start_qi++;
			}
			else
			{
				while(speed_tian[j][start_tian]>speed_qi[j][start_qi])
				{
					win++;
					start_tian++;
					start_qi++;
				}
				if(speed_tian[j][x]<speed_qi[j][start_qi]) lose++;
				start_qi++;
			}
			x--;
		}

		money[j]=win*200-lose*200;
	}
	for(j=0;j<=i-1;j++) printf("%d\n",money[j]);
}


int n;
int tian[1001] = { 0 };
int qi[1001] = { 0 };
int cal(int n)
{
	int result = -200 * n;
	int money =0 ;
	for(int i=0;i<n;i++)
	{
		int k=0;
		while(i+k<n)
		{
			if(tian[k] > qi[i+k])
			{
				k++;
				money += 200;
			}
			else if(tian[k] == qi[i+k])
			{
				k++;
			}
			else
			{
				k = 0;
				money = 0;
				break;
			}
		}
		if(i+k==n)
		{
			if(money - i * 200 > result)
			{
				result = money  - i * 200;
			}
			money = 0;
		}
	}
	return result;
}
int cmp(const void * af, const void *bf)
{
	int *elem1 = (int*)af;
	int *elem2 = (int*)bf;
	return (*elem2 - *elem1);
}
int main()
{
	int n;
	while(cin >> n && n!=0)
	{
		for(int i=0;i<n;i++)
		{
			cin >> tian[i];
		}
		for(int i=0;i<n;i++)
		{
			cin >> qi[i];
		}
		qsort(tian,n,sizeof(int),cmp);
		qsort(qi,n,sizeof(int),cmp);
		int pos = 0;
		cout << cal(n) << endl;

	}
	return 0;
}


int cmp(const void* e1,const void* e2)
{
	return *(int*)e2-*(int*)e1;
}

int main()
{
	int n;
	int King[1000];
	int Tian[1000];

	//??????
	int Win;
	//????
	int Lose;

	int begin;
	int end;

	int i,j;
	while(1)
	{
		Win=0;
		Lose=0;
		cin>>n;
		if(n==0)
			break;

		for(i=0;i<n;i++)
			cin>>Tian[i];
		for(i=0;i<n;i++)
			cin>>King[i];

		qsort(King,n,sizeof(int),cmp);
		qsort(Tian,n,sizeof(int),cmp);
		//??
		begin=0;
		end=n-1;
		//??
		i=0;j=n-1;
		while(i<=j)
		{
			//win
			if(King[i]<Tian[begin])
			{
				Win++;
				begin++;
				i++;
			}

			//lose
			else if(King[i]>Tian[begin])
			{
				Lose++;
				i++;
				end--;
			}

			//tie
			else if(King[i]==Tian[begin])
			{
				while(King[j]<Tian[end] && j>i && end>begin )
				{
					Win++;
					end--;
					j--;
				}
				if(King[j]>Tian[end])
				{
					Lose++;
					i++;
					end--;
				}
				else if(King[j]==Tian[end])
				{
					if(King[i]>Tian[end])
					{
						Lose++;
						end--;
						i++;
					}
					else if(King[i]==Tian[end])
					{
						end--;
						i++;
					}
				}
			}
		}

		cout<<(Win-Lose)*200<<endl;
	}

	return 0;
}


long n;
long tian[1010],king[1010];
void sort(long a[])
{
    long i,j,temp;
    for(i=1;i<n;i++)
    {
         for(j=i+1;j<=n;j++)
         {
                if(a[j]<a[i])
                {
                      temp=a[j];
                      a[j]=a[i];
                      a[i]=temp;
                 }
         }
    }
}

void main()
{
    long i,j,money;
    for(scanf("%ld",&n);n>0;scanf("%ld",&n))
    {
          for(i=1;i<=n;i++)
          {
              scanf("%ld",tian+i);
          }
           for(i=1;i<=n;i++)
          {
            scanf("%ld",king+i);
           }
         sort(tian);sort(king);
         long begin_tian=1,end_tian=n;
          long begin_king=1,end_king=n;
         money=0;
        while(begin_tian<=end_tian)
        {
            while((tian[begin_tian]>king[begin_king])&&(begin_tian<=end_tian))
            {
                      money+=200;
                      begin_tian++;begin_king++;
            }
            while((tian[end_tian]>king[end_king])&&(begin_tian<=end_tian))
            {
                     money+=200;
                     end_tian--;end_king--;
            }
            if(begin_tian<=end_tian)
            {
                   if(tian[begin_tian]<king[end_king])
                    money-=200;
                    begin_tian++;end_king--;
            }
         }
    printf("%ld\n",money);
  }
}


int Mycompare(const void *p1, const void *p2)
{
	return *((int *)p2) - *((int *)p1);
}
int main()
{
	int horseNum, Thorse[1000], Qhorse[1000], i;
	int Th, Tt, Qh, Qt, sum;
	while(cin>>horseNum)
	{
		if(horseNum == 0)
			break;
		for(i=0; i<horseNum; i++)
			cin>>Thorse[i];
		for(i=0; i<horseNum; i++)
			cin>>Qhorse[i];
		qsort(Thorse, horseNum, sizeof(int), Mycompare);
		qsort(Qhorse, horseNum, sizeof(int), Mycompare);
		Th = Qh = 0;
		Tt = Qt = horseNum - 1;
		sum = 0;
		while(Th <= Tt)
		{
			if(Thorse[Th] > Qhorse[Qh])
			{
				sum = sum + 200;
				Th = Th + 1;
				Qh = Qh + 1;
			}
			else if(Thorse[Th] < Qhorse[Qh])
			{
				sum = sum - 200;
				Qh = Qh + 1;
				Tt = Tt - 1;
			}
			else
			{
				if(Thorse[Tt] > Qhorse[Qt])
				{
					sum = sum + 200;
					Tt = Tt - 1;
					Qt = Qt - 1;
				}
				else
				{
					if(Thorse[Tt] < Qhorse[Qh])
					{
						sum = sum - 200;
						Tt = Tt - 1;
						Qh = Qh + 1;
					}
					else
					{
						Tt = Tt - 1;
						Qh = Qh + 1;
					}
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}


int compare(const void *a,const void *b)
{

    int x,y;
    x=*(int *)a;
    y=*(int *)b;
    if (x<y)
          return 1;
    else if (x>y)
          return -1;
        else
        	return 0;
}
int main()
{
    int i,j,k,s,x,n,t[1000],q[1000];
    cin>>n;
    while (n!=0)
    {
          for (i=0;i<n;i++)
                cin>>t[i];
          for (i=0;i<n;i++)
                cin>>q[i];
          qsort(t,n,sizeof(t[0]),compare);
          qsort(q,n,sizeof(q[0]),compare);
          for (i=0;t[0]<q[i] && i<n;i++);
          for (s=-200*n;i<n;i++)
          {
                x=-i*200;
                for (j=i,k=0;j<n;j++,k++)
                {
                      if (t[k]>q[j])
                            x+=200;
                      else if (t[k]<q[j])
                            x-=200;
                }
                if (x>s)
                      s=x;
          }
          cout<<s<<endl;
          scanf("%d",&n);
    }
    return 0;
}


static int cmp(const void *a, const void *b)
{
	return *(int *)b - *(int *)a;
}
int main()
{
	int n;
	int i,j,k;
	int temp;
	int win=0;
	int tie=0;
	int lose=0;
	int tianji[1000];
	int qiwang[1000];
	while(1)
	{
		win=0;
		tie=0;
		lose=0;
		scanf("%d",&n);
		if(n==0)
		{
			break;
		}
		for(i=0;i<n;i++)
		{
			scanf("%d",tianji+i);
		}
		for(i=0;i<n;i++)
		{
			scanf("%d",qiwang+i);
		}
		qsort(tianji,n,sizeof(int),cmp);
		qsort(qiwang,n,sizeof(int),cmp);
		for(j=0;j<n;j++)
		{
			if(qiwang[j]==-1)
			{
				continue;
			}
			for(i=n-1;i>=0;i--)
			{
				if(tianji[i]==-1)
				{
					continue;
				}
				if(tianji[i]>qiwang[j])
				{
					tianji[i]=-1;
					qiwang[j]=-1;
					win++;
					break;
				}
			}
		}
		for(i=0;i<n;i++)
		{
			if(tianji[i]==-1)
			{
				continue;
			}
			for(j=0;j<n;j++)
			{
				if(qiwang[j]==-1)
				{
					continue;
				}
				if(tianji[i]==qiwang[j])
				{
					tianji[i]==-1;
					qiwang[j]==-1;
					tie++;
					break;
				}
			}
		}
		lose=n-win-tie;
		printf("%d\n",(win-lose)*200);
	}
	return 0;
}


int a[1010],b[1010];
int main()
{
    int n;
	int i;
    while(scanf("%d",&n),n)
    {
        for(i=1; i<=n; i++)  scanf("%d",&a[i]);
        for(i=1; i<=n; i++)  scanf("%d",&b[i]);
        sort(a+1,a+1+n);
        sort(b+1,b+1+n);
        int tl=1,tr=n,ql=1,qr=n;
        int sum=0;
        while(tl<=tr)
        {
            if(a[tl]<b[ql])
            {
                qr--;
                tl++;
                sum=sum-200;
            }
            else if(a[tl]==b[ql])
            {
                while(tl<=tr&&ql<=qr)
                {
                    if(a[tr]>b[qr])
                    {
                        sum+=200;
                        tr--;
                        qr--;
                    }
                    else
                    {
                        if(a[tl]<b[qr])  sum-=200;
                        tl++;
                        qr--;
                        break;
                    }
                }
            }
            else
            {
                tl++;
                ql++;
                sum=sum+200;
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}


void paixu(int*p,int k);
int saima(int*p,int*q,int k);
main()
{
      int tian[2020],qi[1010];
      int n,i,j,k,m,max;
      for(;;)
      {
             scanf("%d",&n);
             if(n!=0)
             {
                     for(i=0;i<n;i++)
                     scanf("%d",&tian[i]);
                     for(j=0;j<n;j++)
                     scanf("%d",&qi[j]);
                     paixu(tian,n);
                     paixu(qi,n);
                     max=-n;
                     for(k=0;k<n;k++)
                     tian[n+k]=tian[k];
                     for(i=0;i<n;i++)
                     {
                          m=0;
                          for(j=0;j<n;j++)
                          {
                                if(tian[j+i]>qi[j])
                                m=m+1;
                                if(tian[j+i]<qi[j])
                                m=m-1;
                          }
                          if(m>max)
                          max=m;
                     }
                     printf("%d\n",200*max);
             }
             else
             break;
      }

}
void paixu(int*p,int k)
{
     int i,j,t;
     for(i=0;i<k-1;i++)
     {
          for(j=0;j<k-1-i;j++)
          {
                if (p[j]<p[j+1])
                {
                       t=p[j];
                       p[j]=p[j+1];
                       p[j+1]=t;
                }
          }
     }
}