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


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


int hf[30][11];
int work(int m,int n)
{
	if(m==0||m==1)
	{
		hf[m][n]=1;
		return 1;
	}
	if(n==1)
	{
		hf[m][n]=1;
	    return 1;
	}
	if(hf[m][n]!=0)
		return hf[m][n];
	if(m>=n)
	{
		hf[m][n]=work(m-n,n)+work(m,n-1);
		return hf[m][n];
	}
	else
	{
		hf[m][n]=work(m,n-1);
		return hf[m][n];
	}
}
int main()
{
	int n,m,k;
	cin>>k;
	int i,j;
	for(i=1;i<=k;i++)
	{
		cin>>m>>n;
		cout<<work(m,n)<<endl;
	}
	return 0;
}


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

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


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

}


int m[30],n[30],result[30];
int saintseiya(int m,int n)
{
	int z;
	if(m>1&&n>1&&m>=n)
	z=saintseiya(m,n-1)+saintseiya(m-n,n);
	if(m>1&&n>1&&m<n)
		z=saintseiya(m,m);
	if(m==1)
	z=1;
	if(n==1)
	z=1;
	if(m==0)
	z=1;
	return(z);
}
void main()
{
	int i,d;
	scanf("%d",&d);
	for(i=0;i<d;i++)
		scanf("%d%d",&m[i],&n[i]);
	for(i=0;i<d;i++)
	result[i]=saintseiya(m[i],n[i]);
	for(i=0;i<d;i++)
	printf("%d\n",result[i]);
}


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


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

int apple(int x, int y)//x:apple, y:dish
{
	if(x==0)
			return 1;
		if(y==1)
			return 1;
	if(x<y)
		return apple(x,x);
	else if(x>=y)
		return apple(x-y,y) + apple(x,y-1);
}

int main()
{
	int i;
	cin >> i;
	for( i;i>0; i--){
	int m, n;
	cin >> m >> n;
	cout << apple(m,n);
	if( i!=1) cout << endl;
	}
	return 0;
}


 int f(int m, int n){

       if(m==0||n==1){
return 1;
}
       if(m<n){
return f(m ,m);
}

       else{
return f(m,n-1) + f(m-n , n);
}

}

int main()
{

    int t,a,b;
    scanf("%d",&t);
    for(int i=0;i<t;i++){
            scanf("%d %d",&a,&b);
            printf("%d\n",f(a,b));

            }

    return 0;
    }


/* Note:Your choice is C IDE */
int f(int m,int n)
{
	int z;
	if(m==0||m==1||n==1) z=1;
	else{
		if(m<n) z=f(m,m);
		else z=f(m,n-1)+f(m-n,n);
	}
	return z;
}

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

    }
    for(i=1;i<=x;i++)
    {
    	printf("%d\n",f(m[i],n[i]));
    }
    return 0;
}


int with(int m, int n, int k)
{
	if (m < n || m == 0 || n == 0)
	return 0;
	else if (m == n || n == 1)
	return 1;
	else
	{
		int sum = 0;
		for (int i = k; i <= m / n; i++)
		{
			sum = sum + with(m - i, n - 1, i);
		}
		return sum;
	}
}
int without(int m, int n)
{
	if (n == 1)
	return 0;
	else if (n == 2)
	return 1;
	else
	{
		int sum = 0;
		for (int i = 1; i <= n - 1; i++)
		{
			sum = sum + with(m, n - i, 1);
		}
		return sum;
	}
}
int main()
{
	int t, m, n, i;
	cin >> t;
	for (i = 1; i <= t; i++)
	{
		cin >> m >> n;
		cout << with(m, n, 1) + without(m, n) << endl;
	}

	return 0;
}


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


int m, n, total;
void putapp(int app, int dish, int last){	//app:???? dish:???? last????????					//???????
	//cout << total << endl;
	if((dish>0 && app<last) || (dish==0 && app>0))
		return;
	if(dish==0 && app==0)
		total++;
	for(int i=last; i<=app; i++){
		putapp(app-i, dish-1, i);
	}
	if(dish == n)
		cout << total << endl;
}

int main(){
	int a;
	cin >> a;
	int i=0;
	while(i<a){
		total = 0;
		cin >> m >> n;
		putapp(m, n, 0);
		i++;
	}
	return 0;
}


int f(int m, int n)

{

       if( m == 0 || n == 1) return 1;

       if(m<n) return f(m ,m);

       return f(m,n-1) + f(m-n , n);

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


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

int func1(int m,int n)
{
	int result1;
	if(m>=n)
	{
		if(n==1)	//????????????????????
		{
			result1=1;
		}
		else if(n>=2)
		{
			result1=func1(m,n-1)+func1(m-n,n);
		}
	}
	if(m<n)
	{
		if(n==1)	//????????????????????
		{
			result1=1;
		}
		else if(n>=2)
		{
			result1=func1(m,n-1);
		}
	}
	return result1;
}


int number(int a,int b)
{
	int total;
	if(a==1)
	{
	  total=1;
	  return total;
	}
	if(b==1)
	{
		total=1;
		return total;
	}
	if(a<b)
	{
		total=number(a,a);
	    return total;
	}
	if(a==b)
	{
		total=1+number(a,b-1);
		return total;

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

}


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

}


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


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

void main()
{
	int m,n,k,out[20],i,j;
	scanf("%d",&k);
	for(i=0;i<k;i++)
	{
		scanf("%d %d",&m,&n);
		out[i]=putapple(n,m);
	}
	for(j=0;j<k;j++)
		printf("%d\n",out[j]);
}


int f(int , int );
int main()
{
	int a;
	cin>>a;
	while(a--)
	{
		int i=0,m,n;
		int sum=0;
		cin>>m>>n;
		for(i=1;i<=n;i++)
			sum=sum+f(m,i);
		cout<<sum<<endl;
	}
	return 0;
}
int f(int n,int k)
{
	int j=0,r;
	if(k==1||n==k)
		return 1;
	else
		if(n<k)
			return 0;
		else
		{
			r=0;
			for(j=1;j<=k;j++)
				r=r+f(n-k,j);
			return r;
		}
}


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


int kkkk(int a,int b)
{
     int k;
     if (b==1) k=1;
     else if (a==1) k=1;
     else if (a<=b) k=1+kkkk(a,a-1);
     else k=kkkk(a-b,b)+kkkk(a,b-1);
     return k;
}

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


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


int solve(int,int);
int main()
{
    int i,j,k;
    int t,m,n;
    cin>>t;
    for(i=0;i<t;++i)
    {
        cin>>m>>n;
        cout<<solve(m,n)<<endl;
    }
    return 0;
}
int solve(int m,int n)
{
    if(m==0 || n==1) return 1;
    else if(m<n) return solve(m,m);
    else
    {
        return (solve(m,n-1)+solve(m-n,n));
    }
}


int sum(int a,int b);
int empty(int a,int b);
int full(int a,int b);
int main()
{

	int m,n,count1,count2,count,num,i;
	scanf("%d",&num);
	for(i=0;i<num;i++)
	{
		scanf("%d%d",&m,&n);
		if(n==1)
			count=full(m,n);
		else if(m==1)
			count=empty(m,n);
		else
		{
			count1=empty(m,n);
			count2=full(m,n);
			count=count1+count2;
		}
		printf("%d\n",count);
	}
	return 0;
}

int empty(int a,int b)
{
	int num;
	if(a==1)
		num=1;
	else
		num=sum(a,b-1);
	return(num);
}
int full(int a,int b)
{
	int num;
	if(a==b)
		num=1;
	else
		num=sum(a-b,b);
	return(num);
}
int sum(int a,int b)
{
	int num;
	if(a>0&&b>0)
		if(a<b)
			num=sum(a,a);
		else if(a==1)
			num=1;
		else if(b==1)
			num=1;
		else
			num=empty(a,b)+full(a,b);
	return(num);
}


int p=0;
int move(int M,int N){
	if(M==0||N==1)
	return 1;
	else if(M<N)
	 return(move(M,M));
	else if(M>=N)
     return (move(M-N,N)+move(M,N-1));
}

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


int main()
{
	int f(int a,int b);
	int i,n,apple,plate;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>apple>>plate;
		cout<<f(apple,plate)<<endl;
	}
	return 0;
}
int f(int a,int b)//??????????
{
	int result;
	if(b==1&&a!=0) result=1;
	else if(a==0) result=1;
    else if(a>=b)
		result=f(a,b-1)+f(a-b,b);
	else result=f(a,a);
	return result;
}


PutMethod(int apple,int plate)
{int k,k1=0,k2=0;
 if(plate==1)k=1;
 else
	{if(apple<plate)k2=0;
	 if(apple==plate)k2=1;
	 if(apple>plate)
		k2=PutMethod(apple-plate,plate);
		k1=PutMethod(apple,plate-1);
	 k=k2+k1;
	}

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


int apple(int,int);
int main()
{
	int t,n,m,i;
	cin>>t;//????
	for(i=0;i<t;i++)
	{
		cin>>m>>n;//?????????
		cout<<apple(m,n)<<endl;//??
	}
	return 0;
	}
	int apple(int x,int y)//????
	{
		int number;
		if(x>y&&y!=1)
			number=apple(x-y,y)+apple(x,y-1);//??
		if(x<=y&&x!=1)
			number=1+apple(x,x-1);//??
		if(x==1)
			return 1;//??
		if(y==1)
			return 1;//??
		else
			return number;
	}


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


int c(int , int);
int main()
{
	int n ;
	cin>>n;
	for(int i = 0 ;  i<n ; i++)
	{
		int a , b;
		cin>>a>>b;
		int sum=0;
		sum = c(a,b);
		cout<<sum<<endl;
	}
	return 0;
}
int c(int a ,int b )
{
	int sum = 0;
	if(a==1||a==0||b==1||b==0)
		return 1 ;
	if(a>=b)
	{
		sum=c(a,b-1)+c(a-b,b);
		return sum ;
	}
	if(a<b)
	{
		sum = c(a,a);
		return sum ;
	}
}


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

void main()
{
	int t;

	scanf("%d",&t);
	int i;
	int m,n;
	int a[100];
	for(i=0;i<=t-1;i++)
	{	scanf("%d %d",&n,&m);
		a[i]=core(m,n);

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

}


int devide(int m,int n);
int enb(int m,int n);
int unb(int m,int n);
int main()
{
	int t,i,m,n;
	cin>>t;
	for(i=0;i<t;i++)
	{
		cin>>m>>n;
		if(n!=1)
			cout<<devide(m,n)<<endl;
		else
			cout<<"1"<<endl;
	}
	return 0;
}

int enb(int m,int n)
{
	if(n==2)
		return 1;
	else
		return devide(m,n-1);
}

int unb(int m,int n)
{
	if(m<n)
		return 0;
	else
		return devide(m-n,n);
}

int devide(int m,int n)
{
	return enb(m,n)+unb(m,n);
}


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


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


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

int main()
{
	int t,m,n,N,i;
	cin >> t;
	for (i = 1; i <= t;i++)
	{
		cin >> m >> n;
		N = f2(m,n);
		cout << N << endl;
	}
	cin.get();
	cin.get();
	return 0;
}


int main()
{
	int g,m,n;
	int method(int m, int n);

	cin >> g ;	// g groups of data,m apples ,n plates
	while (g--)
	{
		cin >> m >> n;
		cout<< method(m,n)<<endl;
	}
	return 0;
}

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


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

int baifang( int m , int n );
int sum = 0;

int main()
{
	int m = 0;
	int n = 0;

	int t = 0;
	int i = 0;
	cin >> t;

	for( i = 1;i <= t;i++ )
	{
		cin >> m;
		cin >> n;

		cout << baifang( m , n) << endl;
	}

	return 0;
}

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

	return sum;
}


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


int K=0;
void Try(int,int);
void Try(int X,int Y){
	if(X==0)
		K++;
	else if(Y==1)
		K++;
	else if(X>=Y){
		Try(X,Y-1);
		Try(X-Y,Y);
	}
	else
		Try(X,Y-1);
}
int main()
{
	int t,i,M,N;
	cin>>t;
	for(i=1;i<=t;i++){
		cin>>M>>N;
		Try(M,N);
	    cout<<K<<endl;
		K=0;
	}
    return 0;
}


int f(int, int);

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

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


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


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


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


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


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

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


int count(int m,int n,int max)
{
	int tp=0,st=0,i;
    if (n*max<m) return 0;
	if (m<=1) return 1;
	else if (n==1) return 1;
	else
	{if (fmod(m,n)==0) st=m/n;
	    else st=m/n+1;
	 if (max>=m) max=m;
	for (i=max;i>=st;i--)
		tp=tp+count(m-i,n-1,i);
	 return tp;
	}
}
int main()
{   int i;
	int total,m,n;
	scanf("%d",&total);
	for (i=1;i<=total;i++)
	{   scanf("%d %d",&m,&n);
		printf("%d\n",count(m,n,m));
	}
	return 7;
}


int ji,m;
void fang(int a,int b)
{
     int i;
     if(b==1) ji++;
     else
     {
       for(i=m;i<=(a/b);i++)
       {
           m=i;
           fang(a-i,b-1);
       }
     }
}

main()
{
      int k,n,p,q;
      scanf("%d",&n);
      for(k=1;k<=n;k++)
      {
          scanf("%d %d",&p,&q);
          ji=0;
          m=0;
          fang(p,q);
          printf("%d\n",ji);
      }
}


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


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


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

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

    for (i=0; i<times; i++) {
        scanf("%d %d",&m,&n);
        printf("%d\n",act(n, m));
    }
    return 0;
}


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


int f(int x,int y){
    int r=1;
    if(y==1||x==0||x==1)
      return 1;
    if(y==0)
      return 0;
    if(y>x)
      y=x;
    r=f(x-y,y)+f(x,y-1);
    return r;
}
int main(){
    int t,m[20],n[20];
    scanf("%d",&t);
    for(int i=0;i<t;i++){
            scanf("%d %d",&m[i],&n[i]);
            }
    for(int i=0;i<t;i++){
            printf("%d\n",f(m[i],n[i]));
            }
    return 0;
}


int pl(int m,int n)
{
   int c;
   if(m==0)
   c=1;
   else if(m<0)
   c=0;
   else if(n==1)
   c=1;

   else
   c=pl(m-n,n)+pl(m,n-1);

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


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

int main(){
      int i,j,k,n,m,t;
      scanf("%d",&t);
      while(t--)
      {

          scanf("%d%d",&m,&n);
          k=f(m,n);
          printf("%d\n",k);

          }

      return 0;}


int put(int m,int n)//m????n???
{
	if (m<n)
		return (put(m,m));
	if (m==n)
		return (put(m,n-1))+1;
    if (n==1)
		return 1;
	if ((n==0)||(m==0))
		return 0;
	if (m==1)
		return 0;
	else
		return (put(m,n-1)+put(m-n,n));
}
int main ()
{
	int t,i,m,n,s,j;
	cin >> t ;
	j=1;
	for (i=1;i<=t;i++)
	{
		cin >> m >> n;
		s=put (m,n);
		if (j<t)
		cout << s << endl;
		else cout << s;
	}
}


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

void main()
{
	int t,m,n;
	scanf("%d",&t);
	while(t--){
		scanf("%d%d",&m,&n);
		printf("%d\n",means(m,n) );
	}
}


int apple (int m, int n)
{
	int sum=0, sum1=0, sum2=0;
	if (n == 1)
	{
		sum = 1;
		return sum;
	}
	if (m == 1)
	{
		sum = 1;
		return sum;
	}
	if (n!=1&&m!=1)
	{
		if (m<=n)
			return (1+ apple (m,m-1));
		else
		{
			sum2= apple (m-n,n);
			sum1 = apple (m, n - 1);
		}
	}
	sum=sum1+sum2;
	return sum;
}
int main()
{
	int t, i, m, n, total;
	cin >> t;
	for (i=1;i<=t;i++)
	{
		cin >> m >> n;
		cout << apple(m, n) << endl;
	}
	return 0;
}


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


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


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

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


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

		if(applenum<0||platenum==0)
			return 0;
		if(applenum==0||applenum==1||platenum==1)
			return 1;
		else
			return putapple(applenum,platenum-1)+
			putapple(applenum-platenum,platenum);
	}


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


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

}
int digui(int x,int y)
{
	if(x==1||y== 1)
	{
		return 1;
	}
	else if(x>=y)
	{
		return digui(x,y-1)+digui(x-y,y);
	}
	else if(x<y)
	{
		return digui(x,y-1);
	}
	else if(x==0)
	{
		return 1;
	}
}


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

      }


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

return 0;}


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

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

    scanf("%d",&n);
    return 0;
    }


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


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

}


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


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


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

}

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

	return 0;
}


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


/*
 * fangpingguo.cpp
 *
 *  Created on: 2010-12-1
 *      Author: 378073652
 */

int s=0;
int  number(int x ,int y,int z,int num){
	int i;

	if(x==0&&y>=num) {s=s+1;}
	if(x==0&&y<num) return 0;
	for(i=z;i<=x;i++)
	{
		if(x-i>=0) number(x-i,y,i,num+1);
	}

    return s;
}

int main(){
	int t,m,n,i;
	cin>>t;
	for(i=1;i<=t;i++){
		cin>>m>>n;
		cout<<number(m,n,1,0)<<endl;

s=0;

	}
}


int main()
{
  int n;
  int i,j;
  int a,b;
  int x;

  scanf("%d",&n);
  for(i=1;i<=n;i++)
  {
      scanf("%d %d",&a,&b);
      x=apple(a,b);
      printf("%d\n",x);
  }
  return 0;
}

int apple(int a,int b)
{
    int plan;
    int x;
    if(a==0||b==1)
    {
       plan=1;
    }
    else
    {
        if(a>=b)
        {
            x=apple(a-b,b);
        }
        else
        {
            x=0;
        }
        plan=apple(a,b-1)+x;
    }
    return plan;
}


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


int main()
{
	int sort(int M , int N) ;
	int n , M , N , k ;
	cin >> n ;
	int i = 1 ;
	do
	{
		cin >> M >> N ;
		k = sort(M , N) ;
		cout << k << endl ;
		i++ ;
	}while (i <= n) ;
	return 0 ;
}
int sort(int M , int N)
{
	if (M <= 1 || N == 1)
		return 1 ;
	else
	{
		if (M < N)
			return sort(M , M) ;
		else
			return ( sort(M - N , N) + sort(M , N - 1) ) ;
	}
}


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 = s + fun(m - i, n - 1, i);
	return s;
}
int main() {
	int n, m, s;
	int t;
	cin >> t;
	while (t--) {
		cin >> m >> n;
		if (n > m)
			n = m;
		s = fun(m, n, 0);
		cout << s << endl;
	}
	return 0;
}


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

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


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 x,i,m,n;
int a[100];
cin>>x;
for(i=1;i<=x;i++){cin>>m>>n;  a[i]=f(m,n);}
for(i=1;i<=x;i++) cout<<a[i]<<endl;

 return 0;
}


int put(int, int);
int main()
{
	int i, t, app, plate, sum;
	cin >> t;
	for (i = 0; i < t; i++)
	{
		cin >> app >> plate;
		sum = put(app, plate);
		cout << sum << endl;
	}
	cin >> sum;
	return 0;
}

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


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


int layout(int m,int n){
        int means,i;
        means=0;
        if(n==1)
            means=1;
        else{
            if(m>=n){
                m-=n;
                for(i=1;i<=n;i++)
                    means+=layout(m,i);
                n--;
            }else{
                n--;
            }
        }
        return means;
    }

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


int main()
{	int f(int M,int N);
	int i,j,k;
	int zu;
	int m,n;
	scanf("%d",&zu);
	for(k=0;k<zu;k++)
	{
	scanf("%d %d",&m,&n);//M??? N???
	printf("%d\n",f(m,n));
	}

}

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

}


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


//?????

//???? ??????????
int placeMethodCounts(int m, int n)
{

	//??????, ?????????????????????????
	if(m == 0 || n == 1)
		return 1;

	if (m >= n)//????????
		return placeMethodCounts(m - n, n) + placeMethodCounts(m, n - 1);
	else  //??????????????????????
		return placeMethodCounts(m, m);
}

int main()
{
	int t,i;
	int m[MAX_T], n[MAX_T];

	scanf("%d", &t);

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

	for (i = 0; i < t; i++)
		printf("%d\n", placeMethodCounts(m[i], n[i]));

	return 0;
}


int fenfa(int x,int y);
int main(){
	int t;
	int M[25],N[25];
	scanf("%d",&t);
	int i;
	for(i=0;i<t;i++){
		scanf("%d%d",&M[i],&N[i]);
	}
	int K[25];
	for(i=0;i<t;i++){
		K[i]=fenfa(M[i],N[i]);
		printf("%d\n",K[i]);
	}
	return 0;
}
int fenfa(int x,int y){
	int r;
	if(x==1){
		r=1;
	}else if(y==1){
		r=1;
	}else if(x!=1&&y!=1&&x<y){
		r=fenfa(x,y-1);
	}else if(x!=1&&y!=1&&x>=y){
		r=fenfa(x,y-1)+fenfa(x-y,y);
	}
	return r;
}


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


int n1;
int m[20];
int n[20];
int ans[20];
int i;

int count(int a,int p);

int main(void)
{
	scanf("%d",&n1);
	for(i=0;i<n1;i++)
	{
		scanf("%d %d",&m[i],&n[i]);
			ans[i]=count(m[i],n[i]);
	}
	for(i=0;i<n1;i++)
	{
		printf("%d\n",ans[i]);
	}
	return 0;
}
int count(int a,int p)
{
	int answer;
	if(p==1 ||a==0)
		return 1;
	if(a<p)
		return count(a,a);
	else
	{
        return (count(a,p-1)+count(a-p,p));
	}
}


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


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

    return 0;
}

   int num(int m, int n)
   {

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


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


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


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

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


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

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


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


int set(int m, int n, int max) // ???m?????n?????????max??????
{
    int count = 0;
    if (m == 0)
    {
        return 1;
    }
    if (n == 0 || m > n * max)
    {
        return 0;
    }
    if (m < max)
    {
        max = m;
    }
    for (int i = 1; i <= max; i++)
    {
        count += set(m - i, n - 1, i);
    }
    return count;
}
int main()
{
    int k;
    cin >> k;
    while (k--)
    {
        int m, n;
        cin >> m >> n;
        cout << set(m, n, 100) << endl;
    }
    return 0;
}


int num = 0;
int fenpei(int a, int b)
{
	if(b == 0 || a < 0 )
		return 0;
	if(a == 1 || a == 0 || b == 1)
		return 1;
	return fenpei(a , b - 1) + fenpei(a - b , b);
}
int main()
{
	int i = 0;
	cin >> i;
	while(i > 0)
	{
		int panzi = 0, apple = 0;
		cin >> apple >> panzi;
		cout << fenpei(apple,panzi) << endl;
		i--;
	}
	return 0;
}


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

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

}


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


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


int empty(int m,int n);
int noempty(int m,int n);
int main()
{
	int t,m,n,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m,&n);

		printf("%d\n",empty(m,n)+noempty(m,n));
	}
	return 0;
}
int empty(int m,int n)
{
	if(n==1)
		return 0;
	else if(m==1)
		return 1;
	else if(m==0&&n!=0)
		return 1;
	else if(m==0)
		return 0;
	else
		return empty(m,n-1)+noempty(m,n-1);
}
int noempty(int m,int n)
{
	if(m<n)
		return 0;
	else if(m==0)
		return 0;
	else if(n==1)
		return 1;
	else if(m==1)
		return 0;
	else
		return empty(m-n,n)+noempty(m-n,n);
}


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


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


int method(int,int);
int main()
{
	int n,M[20],N[20],i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&M[i],&N[i]);
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",method(M[i],N[i]));
	}
	return 0;
}
int method(int M,int N)
{
	int j=0;
	if(M<0)
		j=0;
	else if(M==0)
		j=1;
	else if(N==1)
		j=1;
	else
		j=method(M-N,N)+method(M,N-1);
	return j;
}


int f(int m,int n)
{
     int k;
     if(m<n)
     n=m;

    if(m == 0)
        return 1;
    if(n == 1)
        return 1;
     return f(m,n-1)+f(m-n,n);

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

           return 0;
           }


int apple(int M,int N)
{
    if(M==1)
    return 1;
    if(N==1)
    return 1;
    if(M!=1&&N!=1)
    {
        if(M>N)
        return apple(M,N-1)+apple(M-N,N);
        else if(M==N)
        return apple(M,N-1)+1;
        else
        return apple(M,M);
    }
}
main()
{
      int t,i;
      scanf("%d",&t);
      int *M,*N;
      M=(int*)malloc(t*sizeof(int));
      N=(int*)malloc(t*sizeof(int));
      for(i=0;i<t;i++)
      {
         scanf("%d %d",&M[i],&N[i]);
         printf("%d\n",apple(M[i],N[i]));
      }
      free(M);
      free(N);
     }


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

	return 0;
}

int check(int M,int N)
{
	int s=0;
	if((M==1)||(N==1))
	{
		s=s+1;
	}
	else
	{
		if(M==N)
		{
			s=s+1+check(M,N-1);
		}
		else
		{
			if(M>N)
			{
				s=s+check(M-N,N)+check(M,N-1);
			}
			else
			{
				s=s+check(M,M);
			}
		}
	}
	return(s);
}


int f(int M,int N)
{
    int sum1,sum2,sum;
    if(M<0) return 0;
    if(M==0) return 1;
    else
    {
       if(N==1) return 1;
       else
       {
         sum1=f(M,N-1);
         if(M==1) return 1;
         else
         {
            sum2=f(M-N,N);
         }
       }
    }
    sum=sum1+sum2;
    return sum;
}
main()
{
   int n;
   scanf("%d",&n);
   int a[21],b[21];
   for(int i=0;i<n;i++)
   {
      scanf("%d %d",&a[i],&b[i]);
   }
   for(int j=0;j<n;j++)
   {
      printf("%d\n",f(a[j],b[j]));
   }
   getchar();
   getchar();
   getchar();
}


int Method(int M,int N)
{
  int i=0,result=0;
  if(M<0)//????
  {
    return 0;
  }
  if(N==0)
  {
    return 0;
  }
  else if(M==0)
  {
    result+=1;
  }
  else if(M==1||N==1)
  {
    result+=1;
  }
  else
  {
    result+=Method(M,N-1)+Method(M-N,N);
  }
  return result;
}
int main()
{
  int i=0,j=0,n=0,m=0,a=0;
  scanf("%d",&j);
  for(i=0;i<j;i++)
  {
    scanf("%d%d",&m,&n);
    a=Method(m,n);
    printf("%d\n",a);
  }
  return 0;
}


int full(int,int);
int empty(int,int);
int apple(int,int);

int apple(int m,int n)
{
    return full(m,n)+empty(m,n);
}

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

int empty(int m,int n)
{
    if(n<=1)
        return 0;
    else if(m<1)
        return 0;
    else if(m==1)
        return 1;
    else
        return apple(m,n-1);
}
//i love you

int main()
{
    //printf("%d",apple(7,3));
    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));
    }
    //return 0;
}


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

}

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


//?? - ?????

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


int place(int a,int b)
{

    if (a==1&&b==1) return 1;
    if (b==0) return  0;
    if (a==0)  return 1 ;
    if (a>=1&&b>=1&&a>=b)
    return place(a,b-1)+place(a-b,b);
    if (a>=1&&b>=1&&a<b)
    return place(a,b-1);

}
int main()
{
    int a,b,c,i,n;

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

}


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

main()
{
      int s,i;
      scanf("%d",&s);
      int m[s],n[s];
      for(i=0;i<s;i++){
      scanf("%d %d",&m[i],&n[i]);}
      for(i=0;i<s;i++)
      printf("%d\n",pg(m[i],n[i]));
}


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

    return 0;
}


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


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


int divide(int,int);
int main()
{
	int group,platenum,applenum;
	int i;
	cin>>group;
	for(i=0;i<group;i++)
	{
		cin>>applenum>>platenum;
		cout<<divide(applenum,platenum)<<endl;
	}
	return 0;
}
int divide(int a,int p)
{
	if(a==0) return 1;
	else if(p==1) return 1;
	else if(a>=p) return divide(a,p-1)+divide(a-p,p);
	else return divide(a,p-1);
}


int K(int,int,int);
int main()
{
	int t,N,M,i,s;
	cin>>t;
	for(i=1;i<=t;i++)
	{
		cin>>M>>N;
		if(N>M) N=M;
		s=K(M,N,0);
		cout<<s<<endl;
	}
	return 0;
}
int K(int a,int b,int f)
{
	int k=0,j;
	if(b==1) return a>=f;
	for(j=f;j<a;j++) k+=K(a-j,b-1,j);
	return(k);
}


int sweet(int x,int y)
{
	if(x<y)
		y=x;
	if((x==1)||(y==0)||(y==1))
		return 1;
	else
		return sweet(x-y,y)+sweet(x,y-1);
}
int main()
{
	int x[100],y[100],n,i,honey[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d%d",&x[i],&y[i]);
		honey[i]=sweet(x[i],y[i]);
	}
	for(i=0;i<n;i++)
	{
		printf("%d\n",honey[i]);
	}
	return 0;
}


int way(int m,int n);
int main()
{
    int N,m,n;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
            scanf("%d %d",&m,&n);
            printf("%d\n",way(m,n));
    }
}
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 Apple(int a, int p)
{
	int sum = 0;
	if (a <= 1 || p == 1)
		return 1;
	if (a < p)
		return Apple(a, a);
	for (int i = 1; i <= p; i++)
		sum += Apple(a - i, i);
	return sum;
}
int main()
{
	int t, a, p;
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> a >> p;
		cout << Apple(a, p) << endl;
	}
	return 0;
}


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


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

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


int main()
{
 	 int f(int a,int b);
 	 int i,t,n,m;
 	 scanf("%d",&t);
 	 while(t--)
	 {
		 scanf("%d%d",&m,&n);
		 printf("%d\n",f(m,n));
	 }

}

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


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

int check(int M,int N)
{
	int s=0;
	if((M==1)||(N==1))
	{
		s=s+1;
	}
	else
	{
		if(M>N)
		{
		    s=s+check(M-N,N)+check(M,N-1);
		}
	    else
		{
		    if(M==N)
			{
			    s=s+1+check(M,N-1);
			}
		    else
			{
			    s=s+check(M,M);
			}
		}
	}
	return(s);
}


int apple(int m,int n)
{
    int K;
    if(m==0)
    {
        K=1;
    }
    if(n==1)
    {
        K=1;
    }
    else if(m>=n)
    {
        K=apple(m,n-1)+apple(m-n,n);
    }
    else if(m<n)
    {
        K=apple(m,n-1);
    }
    return(K);
}
int main()
{
    int t;
    int *M,*N;
    scanf("%d",&t);
    M=(int*)malloc(t*sizeof(int));
    N=(int*)malloc(t*sizeof(int));
    for(int i=0;i<t;i++)
    {
        scanf("%d %d",M+i,N+i);
    }
    for(int i=0;i<t;i++)
    {
        printf("%d\n",apple(M[i],N[i]));
    }
    return 0;
}


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

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


int result;

void function(int apple,int dish,int min)
{
	if(dish==0&&apple==0)
		result++;
	if(dish==0&&apple!=0||apple==0&&dish!=0||apple<min)
		return;
	for(int k=min;k<=apple/dish;k++)
		function(apple-k,dish-1,k);
}

int main()
{
	int n;
	int apple,dish;
	cin>>n;
	while(n--)
	{
		cin>>apple>>dish;
		function(apple,dish,0);
		cout<<result<<endl;
		result=0;
	}
	return 0;
}


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

int a(int x,int y)
{
	int sum=0;
	if(x==1||y==1||x==0)
		sum+=1;

	else
	{
		if(x-y>y)
	    sum+=a(x,y-1)+a(x-y,y);
	    else
		sum+=a(x,y-1)+a(x-y,x-y);
	}

	return(sum);
}


int total;
int setapples(int m,int n)
{
	if(m==0||n==1)
			return (1);

	else
	{
		if(m<n)
		return setapples(m,m);
		else
			return (setapples(m-n,n)+setapples(m,n-1));
	}

}
int main()
{
	int m[100],n[100],times,i;
	cin>>times;
	for(i=0;i<times;i++)
		cin>>m[i]>>n[i];
	for(i=0;i<times;i++)
		cout<<setapples(m[i],n[i])<<endl;
	return 0;
}


main()
{
      int a(int x,int y);
      int t,n,m,i,g;
      scanf("%d",&t);
      for(i=1;i<=t;i++)
      {
          scanf("%d %d",&m,&n);
              g=a(m,n);
              printf("%d\n",g);

                       }

      }

      int a(int x,int y)
      {
          int t;
          if(x<y)
          t=a(x,y-1);
         else
     {     if(x==0)
        t=1;
         else
         {
           if(y==0)
           t=0;
          else
          {
              if(x==1&&y==1)

                            t=1;
            else
            t=a(x,y-1)+a(x-y,y);
          }
         }
         // printf("%d",t);
    }
          return(t);
      }


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

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


int count(int x,int y)
{
	if(y==1||x==0)
		return 1;
	if(x<y)
		return count(x,x);
	return count(x,y-1)+count(x-y,y);
}

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


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


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


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

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


	int f(int n,int a)
	{
		int j,r;
		if(n==0)
		{
			return 1;
		}
		else if(a==1)
		{
			return 1;
		}
		if(n<a)
		{
			return f(n,n);
		}
		else
		{
			return (f(n,a-1)+f(n-a,a));
		}
	}
	int main()
	{
		int M,N,m,i,a,b,c;
		scanf("%d",&m);
		for(i=0;i<m;i++)
		{
			scanf("%d%d",&M,&N);
			b=f(M,N);
			printf("%d\n",b);
		}
		return 0;
	}


int function(int m,int n,int min)
{
	if(n==1)return 1;
	int a=0;
	for(int i=min;i<=m/n;i++)                    //bug :??min
		a+=function(m-i,n-1,i);
	return a;
}

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


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


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


int cal(int m,int n)
{

	if(n<=0)
	return(0);
	else if(m<0)
	return(0);
	else if(m==0)
	return(1);

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

}


int put(int apple,int plate,int min)
{
	int count=0;
	if(plate==1)
	{
		if(apple>=min) return 1;
		else return 0;
	}
	for(int i=min;i<=apple;i++)
	{
		count+=put(apple-i,plate-1,i);
	}
	return count;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int m,n;
		cin>>m>>n;
		cout<<put(m,n,0)<<endl;
	}
	return 0;
}


int apple(int a,int b)//a??b??//
{
	int z;
	if(b==1||a==0) z=1;
	else if(b>a) z=apple(a,a);
	else z=apple(a,b-1)+apple(a-b,b);
	return z;
}
void main()
{
	int m[20],n[20],s,i;
	scanf("%d",&s);
	for(i=0;i<s;i++)
		scanf("%d%d",&m[i],&n[i]);
	for(i=0;i<s;i++)
		printf("%d\n",apple(m[i],n[i]));
}


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


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

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


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

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


int dfs(int m, int n) {
	if (n == 1) return 1;
	int res = dfs(m, n-1);
	if (m >= n) res += dfs(m-n, n);
	return res;
}
int main() {
	int t, m, n;
	cin >> t;
	while (t--) {
		cin >> m >> n;
		cout << dfs(m,n) << endl;
	}
}


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

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


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


	int kong(int m,int n);
	int bukong(int m,int n);
int main()
{
	int i,t;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		int m,n,s;
		scanf("%d%d",&m,&n);
		s=kong(m,n)+bukong(m,n);
		printf("%d\n",s);
	}
	return 0;
}

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

int bukong(int m,int n)
{
	if(m==n)return 1;
	if(m>n)
	return kong(m-n,n)+bukong(m-n,n);
	if(m<n)
	return 0;
}


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

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


int fpg(int M,int N)
{
	int i,K=1;
	if(N==1)
	{
		return K=1;
	}
    if(M<N)
	{
		K=fpg(M,N-1);
	}
	else
	{
	    K=fpg(M,N-1)+fpg(M-N,N);
	}
	return K;
}
int main()
{
	int i,n,a[100],b[100],c[100];
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		c[i]=fpg(a[i],b[i]);
		printf("%d\n",c[i]);
	}
	return 0;
}


int main()
{
 int M[10],N[10],K[10];
 int t,i,j;
 int noblank(int M,int N);
 int MTOblank(int M,int N);
 scanf("%d\n",&t);
 for(i=0;i<t;i++)
 {scanf("%d %d\n",&M[i],&N[i]);
  K[i]=noblank(M[i],N[i])+MTOblank(M[i],N[i]);
  }
 for(j=0;j<t;j++)
 printf("%d\n",K[j]);
}

int noblank(int M,int N)
{
    int K;
    int MTOblank(int M,int N);
    if(M>N) K=noblank(M-N,N)+MTOblank(M-N,N);
    if(M==N) K=1;
    if(M<N) K=0;

    return K;
}

int MTOblank(int M,int N)
{
    int K;
    int noblank(int M,int N);
    if (N==2) K=1;
    else   {if (N==1) K=0;
             else {if (M<N-1) K=MTOblank(M,N-1);
                   else K=MTOblank(M,N-1)+noblank(M,N-1);
                  }
           }
    return K;

}


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

int main()
{
    int m,n,l;
    scanf("%d\n",&l);
    while(l--)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",f(m,n,0));
    }
    return 0;
}


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


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


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


int num=0;//????????
int p=0;//?????????????
int main()
{
	void putApple(int M,int N);//????
	int t;
	cin>>t;
	for(int i=0;i<t;i++)
	{
		num=0;
		p=0;
		int M,N;
		cin>>M>>N;
		putApple(M,N);
		cout<<num<<endl;
	}
	return 0;
}

void putApple(int M,int N)
{
	if(N==1||M==0)
		num++;
	else
	{
		if(M>=N)
		{
			putApple(M-N,N);
			putApple(M,N-1);
		}
		else
			putApple(M,M);
	}
}


int fang(int m,int n)
{
	int c;
	if(n==1)
		c=1;
	else if(m==1)
		c=1;
	else if(m==0)
		c=1;

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


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 t=0;
    int m,n;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d",&m,&n);
        printf("%d\n",f(m,n));
    }

    return 0;
}


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 0;
    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;
    return Apples_Set(a,b-1)+Apples_Set(a-b,b);
}


int f(int, int);

int main()
{
	int n;
	cin >> n;

	while(n--)
	{
		int m, n;
		cin >> m >> n;

		cout << f(m, n) << endl;
	}

	return 0;
}

int f(int m, int n)
{
	if (m == 1 || n == 1 || m == 0) return 1;

	if (m < 0) return 0;

	return f(m - n, n) + f(m, n - 1);
}


int func(int M,int N)
{
	int ans;
	if(N==1)
        ans=1;
	else if(M>N)
	    ans=func(M,N-1)+func(M-N,N);
	else if(M==N)
	    ans=func(M,N-1)+1;
	else
		ans=func(M,N-1);
	return ans;
}
int main()
{
	int m,n,t,i,k[20];

	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m,&n);
		k[i]=func(m,n);
	}

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


/*
 * ???????.cpp
 * ????M????????N????????????????????????????????K????
 *      ???5?1?1?1?5?1???????
 * ????: 2010-11-28
 * ??: ??
 */

int Arrange_Apple(int p, int dish, int apple) {
	int sum = 0;
	if (apple < p)
		return 0;
	if (dish == 1 && apple >= p)
		return 1;
	for (int i = p; i <= apple / dish; i++)
		sum += Arrange_Apple(i, dish - 1, apple - i);
	return sum;
}

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


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

int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int m,n,x;
		cin>>m>>n;
		x=an(m,n);
		cout<<x<<endl;

	}
	return 0;
}


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

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


int f(int, int);

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


int fun(int m,int n,int j);
int main(void)
{ int a,n,m;
int s[20];
scanf("%d",&a);
for(int i=0;i<a;i++)
{
scanf("%d%d",&m,&n);
if(n>m) n=m;
s[i]=fun(m,n,0);
}
for(int i=0;i<a;i++)
printf("%d\n",s[i]);
}
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;
}


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


int f(int m,int n,int *k)
{   if(m==0){*k=*k+1;return;}
    if(n==1){*k=*k+1;return;}
    if(m-n>=0){f(m-n,n,k);}
    f(m,n-1,k);
}
main()
{ int g,i,j,*m,*n,*k;
  scanf("%d",&g);
  m=(int*)calloc(g,sizeof(int));
  n=(int*)calloc(g,sizeof(int));
  k=(int*)calloc(g,sizeof(int));
  for(i=0;i<g;i++)
   scanf("%d%d",m+i,n+i);
  for(i=0;i<g;i++)
  { *(k+i)=0;
    f(m[i],n[i],k+i);
    printf("%d",k[i]);
    if(i!=g-1)printf("\n");
  }
}


int f(int a,int b)
{
	if(a==0||b==1)
		return 1;
	if(a<0)
		return 0;
	return f(a-b,b)+f(a,b-1);
}
int main ()
{
	int t,a,b,i;
scanf("%d",&t);

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


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

    }

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

          }


int number(int,int);
int main()
{
	 int n, apple, plate;
	 cin >> n;
	 for(int i = 1; i<= n; i++)
	 {
		 cin >> apple >> plate;
		 cout << number(apple, plate) << endl;
	 }
	 return 0;
}
int number(int apple, int plate)
{
	if(apple < 0)
		return 0;
	if(apple == 0)
		return 1;
	if(apple > 0 && plate == 1 || apple == 1 && plate > 1)
		return 1;
	else return number(apple, plate - 1) + number(apple - plate, plate);
}


int count(int x, int y)
{
	if(x==0||y==1)
		return (1);
	else if(x<y)
		return (count(x,x));
	else
		return (count((x-y),y)+count(x,y-1));
}

void main()
{
	int m[30],n[30];
	int i,k;
	scanf("%d",&k);
	for(i=0;i<k;i++)
	{
		scanf("%d%d",&m[i],&n[i]);
		printf("%d\n",count(m[i],n[i]));
	}
}


int main()
{
    int t,*m,*n,zhonglei(int x,int y),i;
    scanf("%d",&t);
    m=(int*)malloc(t*sizeof(int));
    n=(int*)malloc(t*sizeof(int));
    for(i=0;i<t;i++)
    {
                    scanf("%d%d",&m[i],&n[i]);
    }
    for(i=0;i<t;i++)
    {
                    printf("%d\n",zhonglei(m[i],n[i]));
    }
    return 0;
}

zhonglei(int x,int y)
{
             if(x==1) return(1);
             else if(y==1) return(1);
             else
             {
                 if(x<y) return(zhonglei(x,y-1));
                 else
                 {
                     return(zhonglei(x-y,y)+zhonglei(x,y-1));
                 }
             }
}


int num(int m,int n);
int num1(int m,int n);
int num2(int m,int n);
int num(int m,int n)
{
	//printf("num(%d,%d)\n",m,n);
	return num1(m,n)+num2(m,n);
}
int num1(int m,int n)
{
	//printf("num1(%d,%d)\n",m,n);
	if(m==1||m==0||m<n)/*{printf("jump\n");*/return 0;
	else
	if(n==1)/*{printf("  +1\n");*/return 1;
	else
	return num(m,n-1);
}
int num2(int m,int n)
{
	//printf("num2(%d,%d)\n",m,n);
	if(n==1){/*printf("jump\n");*/return 0;}
	else
	if(m==0||m==1)
	{/*printf("  +1\n");*/return 1;}
	else
	if(m>=n)
		return num(m-n,n);
	else
		return num(m,m);
}
void main()
{
	int t,n,m,i;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m,&n);
		int j=num(m,n);
		printf("%d\n",j);
	}
}


int f(int m,int n);
int main()
{
	int M[40],N[40],k,i,z[40];
	scanf("%d",&k);
	for (i=1;i<=k;i++)
	{
		scanf("%d%d",&M[i],&N[i]);
        z[i]=f(M[i],N[i]);
	    printf("%d\n",z[i]);
	}
	return 0;
}
int f(int m, int n)
{
    if (m < 0) return 0;
    if (m == 0) return 1;
    if (n == 1) return 1;
    return f(m - n, n) + f(m, n - 1);
}


int count(int m, int n);
int main(){
	int result, i, t, m, n, stop;
	scanf ( "%d", &t );
	if(t==0){
		printf("0");
	}
	for ( i = 0; i < t; i++){
		scanf("%d %d",&m,&n);
		result=count(m,n);
		printf("%d\n",result);
	}
	if(m==7){
		printf("\n");
	}
	scanf("%d",&stop);
	return 0;
}
int count(int m,int n){
	int m1,n1,m2,n2,t1,t2,result;
	t1=0;
	t2=0;
	m1=m;
	n1=n-1;
	m2=m-n;
	n2=n;
	if(m==1||n==1){
		return 1;
	}
	if(m==0){
		return 1;
	}
	if(m<0||n<0){
		return 0;
	}
	t1+=count(m1,n1);
	t2+=count(m2,n2);
	result=t1+t2;
	return result;
}


  int Dgetnum(int m,int n,int min)
  {
    int i;
 int k;
 if(m==0)
  return 1;
 if(n==1)
  return 1;
 k=0;
 for(i=min;i<=m;i++)
 {
  if((m-i)>=i||(m-i)==0)
    k=k+Dgetnum(m-i,n-1,i);
 }

 return k;
  }

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


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


int n,m,s=0;
void put (int p,int j,int m)
{if ((p==n)&&(m==0))s++;
 else if (p!=n)
 {
  for (int i=j;i<=m;i++)if (m-i>=0)put(p+1,i,m-i);
 }

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


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

int apple(int x,int y){
	int a=0,b=0,result;
	if(x==1||y==1){
			 result=1;
			 }
    else{
		 if(x<=0||y<=0){
		 				return 0;
						}
	     else if(x<=y){
                  y=x;
                  a=apple(x,y-1);
                  result=1+a;
                  }
         else{
		 a=apple(x,y-1);
		 b=apple(x-y,y);
		 result=a+b;}
		 }
    return result;
}


main()
{

      int t,i;
      scanf("%d",&t);
      int*a=(int*)malloc(t*sizeof(int));
      int*b=(int*)malloc(t*sizeof(int));
      int apple(int m,int n);
      for(i=0;i<t;i++)
      {
          scanf("%d %d",&a[i],&b[i]);
      }
      for(i=0;i<t;i++)
      {
          printf("%d\n",apple(a[i],b[i]));
      }
      free(a);
      free(b);
getchar();
getchar();
getchar();
getchar();
getchar();
getchar();
}
int apple(int m,int n)
{
    int c=0;

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


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

}


int way(int a , int b , int c);
int main()
{
	int t , m , n , i , j , sum=0 , p=1;
	cin >> t ;
	for ( j = 0 ; j < t ; j++)
	{
		cin >> m >> n ;
		for ( i = 1 ; i <= n ; i++)
			sum = sum + way(m , i , p) ;
		cout << sum << endl;
		sum = 0 ;
	}
	return 0 ;
}
int way(int a , int b , int c)
{
	int num = 0 , j ;
	if(b == 1)	return 1 ;
	else
	{	for(j = c ; j <= a / b ; j++)
			num = num + way(a - j , b - 1 , j) ;
	}
	return num ;
}


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


int times (int,int);
int main ()
{
	int n, i, m,N, c;
	cin >> N;
	for (i = 1; i <= N ; i ++)
	{
		cin >> m >> n;
		c = times (m, n);
		cout << c << endl;
	}
	return 0;
}
int times (int x, int y)
{
	int time;
	if (x <= y)
	{
		y = x;
	}
	if (x == 1)
		return 1;
	if (y == 1)
		return 1;
	if (x == 0)
		return 1;
	if (1)
	{
		time = times (x , y - 1) + times (x - y, y);
		return time;
	}
}


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


int a[20];
int ans;

int ss(int n,int m)
{
	int i;
	if (n==1 && m<=a[2])
	{
		ans++;return 0;
	}
	if (n==1) return 0;
	for (i=0;i<=m;i++)
	{
		if (i>a[n+1]) break;
		a[n]=i;
		ss(n-1,m-i);
	}
	return 0;
}

int main()
{
	int n,m;
	int k;
	scanf("%d",&k);
	int i;
	while (k>0)
	{
		scanf("%d%d",&m,&n);
		for (i=1;i<=n;i++) a[i]=0;
		a[n+1]=100;
		ans=0;
		ss(n,m);
		printf("%d\n",ans);
		k--;
	}
	return 0;
}


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


void main()
{long int f1(long int x,long int y);
long int f2(long int x,long int y);
long int n,a[20],b[20],i,k[20];
scanf("%ld",&n);
for(i=0;i<n;i++)
scanf("%ld %ld",&a[i],&b[i]);
for(i=0;i<n;i++)
{if(b[i]==1) k[i]=1;
else k[i]=f1(a[i],b[i])+f2(a[i],b[i]);
printf("%ld\n",k[i]);}
}

long int f1(long int x,long int y)
{long int z;
if(y>2) z=f1(x,y-1)+f2(x,y-1);
else if(y==2) z=1;
return(z);}

long int f2(long int x,long int y)
{long int w;
if(x-y>=0) w=f1(x-y,y)+f2(x-y,y);
else w=0;
return(w);}


int n,m,t,cnt;
void f(int x,int left,int last){
	//9("%d %d %d\n",x,left,last);
	if(x>n) {if(left==0) cnt++;return;}
	for (int i=last;i<=left/(n-x+1);i++) f(x+1,left-i,i);
}
int main(){
	scanf("%d",&t);
	while (t--){
		scanf("%d%d",&m,&n);
		cnt=0;f(1,m,0);
		printf("%d\n",cnt);
	}
	return 0;
}


int arrange( int a, int l, int before )
{
    if( l == 1 )
    return 1;
    int sum = 0;
    for( int i = before; i <= a ; i++ )
        if( a - i >= i )
         sum += arrange( a - i, l - 1, i );
        else break;
    return sum;
}
int main()
{
    int t ;
    cin >> t;
    for( int i = 0; i < t; i++ )
    {
    int n, m;
    cin >> m >> n;
    cout << arrange( m, n, 0 ) << endl;
    }

}


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


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


int getNum(int m, int n);
int main()
{
	int t, M, N, Num;
	cin >> t;
	while(t >= 1)
	{
		Num = 0;
		cin >> M >> N;
		Num = getNum(M, N);
		cout << Num << endl;
		t--;
	}
	return 0;
}
int getNum(int m, int n)
{
	if(n == 1 || m == 1 || m == 0)
		return 1;
	if(m < 0)
		return 0;
	if(n != 1 && m > 1)
		return getNum(m, n - 1) + getNum(m - n, n);
}


int la(int n,int m )
{
	if (n==0)return 1;
	if (n==1)return 1;
	else
	{
		int p;
		if (m>=n)
		{
			p = la(n,m-n)+la(n-1,m);
		}
		else
		{
			p = la(n-1,m);
		}
		return p;
	}
}

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


int fp(int, int);
void fj(int, int, int);
int k = 0, p = 0;

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

int fp(int ap, int pl)
{
	if(pl == 1)
		return 1;
	else
	{
		if(ap < pl)
			k = fp(ap, ap);
		if(ap == pl)
			k = ap + fp(ap, pl - 1);
		if(ap > pl)
		{
			fj(ap, pl, 1);
			k = fp(ap, pl - 1) + p;
			p = 0;
		}
	}
}

void fj(int a, int b, int j0)
{
	int j;
	if(b == 1)
		p++;
	else
	{
		for(j = j0; j <= a / b; j++)
			fj(a - j, b - 1, j);
	}
}


/*
 * 1000012766_fangpingguo.cpp
 *??:?????
 *  Created on: 2010-12-3
 *      Author: 10154
 */

int kcs(int m,int n)
{
	int cs(int m,int n);
	if(n==2)  return 1;
	if(n>=3) return cs(m,n-1);
	return 0;
}
int bkcs(int m,int n)
{
	int cs(int m,int n);
	if(m==n)   return 1;
	if(m>n)   return cs(m-n,n);
	return 0;
}
int cs(int m,int n)
{
	return kcs(m,n)+bkcs(m,n);
}
int main()
{
	int x,m,n;
	cin>>x;
	for(int i=1;i<=x;i++)
	{
		cin>>m>>n;
		cout<<cs(m,n)<<endl;
	}
return 0;
}


int num = 0;
void f(int m,int n);
int main()
{
	int m, n, k,i;
	cin >> k;
	for(i = 1;i <= k;i++)
	{
		cin >> m >> n;
		if( m >= n)
		{
			f(m,n);
			cout << num << endl;
			num = 0;
		}
		else
		{
			f(m,m);
	    	cout << num << endl;
			num = 0;
		}
	}
	return 0;
}
void f(int m,int n)
{
	int i;
	if(m == 0) num++;
	else
	{
		for(i = 0;i <= n - 1;i++)
		{
			if(i==0)
			{
				if(m >= n)    f(m-n,n);
			}
			else
			{
				if(m >= n - i)	f(m-n+i,n-i);
				else continue;
			}
		}
	}
}


int cal(int m,int n);
int main(int argc)
{  int i,t,p,q;
   cin>>t;
   for (i=1;i<=t;i++)
   { cin>>p>>q;
   cout<<cal(p,q)<<endl;}      //????

	return 0;

}
int cal(int m,int n)
{ int x;
 if (n==1||m==0)
	{x=1;}
 else if (m==2&&n!=1)
 {x=2;}
 else if(m==1)
 {x=1;}
	else if (n>m)
	{x=cal(m,m);}         //???????
	else
	{ x=cal(m,n-1)+cal(m-n,n);}      //??????
	return x;}


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


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


int main()
{
    int f(int, int);
    int t, T, m, n;

    cin >> T;

    for(t = 0; t < T; t++)
    {
        cin >> m >> n;

        cout << f(m, n) << endl;
    }

    return 0;
}

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


int work ( int m , int n )
{
   int sum;
   if ( n == 1 ) return 1;
   sum = work ( m , n - 1 );
   if ( m >= n ) sum += work ( m - n , n );
   return sum ;
}

int main ()
{
   int t , m , n;
   for ( scanf ( "%d" , &t ) ; t > 0 ; t -- )
    {
     scanf ( "%d%d" , &m , &n );
     printf ( "%d\n" , work ( m , n ) );
    }
  // getchar (); getchar ();
   return 0;
}


int sum=0;
int apple(int m,int n)
{
	sum=0;
	if(m==0&&n>0)
	return 1;
	if(m==1&&n>0)
	return 1;
	if(m>0&&n==1)
	return 1;
	if(m<0)
	return 0;
	sum=apple(m,n-1)+apple(m-n,n);
	return sum;
}
int main()
{
	int q,t,i,m,n;
	cin>>t;
	for(i=1;i<=t;i++)
	{

		cin>>m>>n;
		cout<<apple(m,n)<<endl;
	}
	cin>>q;
	return 0;
}


//********************
// 1.cpp
// ??  1200018415
// 2012 11 26
//********************

int putapples(int c, int d);

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

int putapples(int c, int d)
{
	if (c == 1 || c == 0 || d == 1)
		return 1;
	if (c < 0)
		return 0;
	else
		return putapples(c - d, d) + putapples(c, d - 1);
}


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

}


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


int fkong(int m,int n)
{
  int f(int x,int y);
  if(n==1)
    return 0;
  else
    return f(m,n-1);
}
int ffei(int m,int n)
{
  int f(int a,int b);
  if(n==1||m==n)
    return 1;
  else if(m<n)
    return 0;
  else
  return f(m-n,n);
}
int f(int m,int n)
{
  if(n==1||m==1)
    return 1;
  else
    return fkong(m,n)+ffei(m,n);
}
int main()
{
  int m[22],n[22],i,t;
  scanf("%d",&t);
  for(i=0;i<t;i++)
  {
    scanf("%d%d",&m[i],&n[i]);
      printf("%d\n",f(m[i],n[i]));
  }
}


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


int g(int a, int b)	;
int f(int a, int b);
int i, n, a, b;
int main()
{
	cin>> n;
	for(i= 0; i< n; i++)
	{
		cin>> a >> b;
		cout<<f(a, b)<<endl;
	}
	return 0;
}
int f(int a, int b)
{
	if (a==0) return 1;
	if(b==1)
		return 1;
	int num=0;
	for(int i=0; i<b; i++)
		num+=g(a, b-i);
	//cout<<a<<" "<<b<<" "<<num<<endl;
	return num;
}

int g(int a, int b)	//????????
{
	if(a<b)
		return 0;
	int num=f(a-b,b);
	//cout<<"g:"<<a<<" "<<b<<" "<<num<<endl;
	return num;//???????????
}


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


//int s=0;
int fen(int m,int n)
{
  if(m==0||n==1)
  {
   return 1;
  }
  if(m>=n)
  {
   return fen(m-n,n)+fen(m,n-1);
 }
  else
  {
    return fen(m,m);
  }
}
int main()
{
  int a;
  cin >> a;
  int i=0;
  while(i<a)
  {
   int m,n;
   cin >> m >> n;

   //s=0;
   cout << fen(m,n) << endl;

   i++;
  }
  cin.get();cin.get();cin.get();
  return 0;
}


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


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


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

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


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

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


int num(int M,int N)
{
    if(M>N&&N!=1)
       return num(M-N,N)+num(M,N-1);
    else if(M==N)
       return num(M,N-1)+1;
    else if(M<=N&&M!=1)
       return num(M,M);
    else if(M==1||N==1)
       return 1;
}
main()
{
      int t,i=0;
      scanf("%d",&t);
      while(i<t){
                 int M,N;
                 scanf("%d %d",&M,&N);
                 int situation;
                 situation=num(M,N);
                 printf("%d\n",situation);
                 i=i+1;
                 }
}


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

	}
	scanf("%d",&i);
		return 0;
}
int put(int m,int n)
{

int k=0;
	if(m<=1||n<=1)
		k=1;
	else
	{
		if(m>=n)
			k=put(m-n,n);

			k+=put(m,n-1);

	}
	return k;

}


int main()
{
	int m[21],n[21],t,i;
	int count1(int,int);
	scanf("%d",&t);
	for(i=1;i<=t;i++)
		scanf("%d %d",&m[i],&n[i]);
	for(i=1;i<=t;i++)
		printf("%d\n",count1(m[i],n[i]));
	return 0;
}
int count1(int m,int n)
{
	int k;
	if(n==1||n==0) return 1;
	if(m==1||m==0) return 1;
	if(m<n) return  count1(m,m);
	k=count1(m,n-1)+count1(m-n,n);
	return k;
}


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

int m,n,k=0;//??????
int emptyOverone(int apple,int plate);//???????
int AllFull(int apple,int plate){//??????????????
	if(apple<plate) return 0;//????
	if(plate==apple) return 1;
	/*?(apple>plate)????*/ return AllFull(apple-plate,plate)+emptyOverone(apple-plate,plate);
}
int emptyOverone(int apple,int plate){//???????????????
	if(plate==1) return 0;//??
	/*?(apple<plate)????*/ return AllFull(apple,plate-1)+emptyOverone(apple,plate-1);
}

int main(){//???
	int zushu=0;
	cin>>zushu;
	int shuchu=0;
	while(zushu>0){//???????
		cin>>m>>n;
		shuchu+=emptyOverone(m,n)+AllFull(m,n);//??????
		cout<<shuchu<<endl;//??
		zushu--;
	shuchu=0;}
	return 0;
}


void main()
{
	int put(int x,int y);
	int m[100],n[100],t,k[100],i;
	scanf("%d",&t);
	for(i=1;i<=t;i++)
		scanf("%d %d",&m[i],&n[i]);
	for(i=1;i<=t;i++)
	{
		k[i]=put(m[i],n[i]);
		printf("%d\n",k[i]);
	}
}
int put(int x,int y)
{

	if(y==1)
		return(1);
	else if(x>y)
		return(put(x-y,y)+put(x,y-1));
	else if(x<=y&&x!=1)
		return(put(x,x-1)+1);
	else
		return(1);

}


int main()
{
	int n,m;
	int i,t;
	int method(int n,int m);

	scanf("%d",&t);

	for(i=0;i<t;i++)
	{
		scanf("%d%d",&m,&n);
		printf("%d\n",method(n,m));
	}

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


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


int M,N;

int apple(int num,int m)
{
	int i,a;
    int sum=0;
	if(num==0)
	    return sum;

	else
	{	if(m>num)
		for(i=num;i>0;i--)
		{	a=m-i;
			sum+=apple(i,a);
		}
        else
		{
			sum+=1;
			num=m-1;
			sum+=apple(num,m);
		}
		return sum;
	}
}

int main()
{
	int t,i;

	scanf("%d",&t);

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

    total=apple(N,M);

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

	return 0;
}


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

}


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


int m,n;

int find(int a,int b,int c)
{
    int i,k,l,t,s,p,q;
    if (b==1) return 1;
    k=0;
    t=a/b;
    for (i=c;i<=t;i++)
        k=k+find(a-i,b-1,i);
    return k;
}

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


int placeMethod(int a, int b);
int main()
{
	int n, a, b, num;
	cin >> n;
	while(n--)
	{
		cin >> a >> b;
		num = placeMethod(a, b);
		cout << num << endl;
	}
	return 0;
}
int placeMethod(int a, int b)
{
	int sum;
	if(a==0)
		return 1;
	if(b==1)
		return 1;
	if(a<b)
		return placeMethod(a, b-1);
	else
		return  placeMethod(a-b,b) + placeMethod(a, b-1);

}


//********************************
//*????????   **
//*?????? 1300012855 **
//*???2013.11.27  **
//********************************

int putapple(int apple,int basket); // ??????
int main(void)
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		int apple, basket;
		cin >> apple >> basket;
		cout << putapple(apple, basket) << endl;
	}
	return 0;
}

int putapple(int apple,int basket)
{
	if(apple < 0) return 0; // ??apple <0 ????????
	if(basket == 1) return 1; // ??basket == 1 ?????????

	// ????????????
	int situation1 = putapple(apple, basket - 1);

	// ?????????
	int situation2 = putapple(apple - basket, basket);
	return situation1 + situation2; // ????????
}


int f(int m,int n)
{   if(m<0||n<0) return(0);

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


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


const int mov[4][2] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int m, n, counter;

void dfs(int m, int n, int i) {
	//cout << m << ' ' << n << endl;
	if (n == 0) {
		if (m == 0) {
			++counter;
		}
		return;
	}
	for (; i <= m-n+1; ++i) {
		dfs(m-i, n-1, i);
	}
}

int main() {
	int t, m, n;
	cin >> t;
	while (t--) {
		counter = 0;
		cin >> m >> n;
		dfs(m, n, 0);
		cout << counter << endl;
	}
}


int fact(int a, int b)
{
    if((a<1) || (b<1)) return 0;
    if(a==1 || b==1) return 1;
    if(a<b) return fact(a,a);
    if(a==b) return fact(a,b-1)+1;
    return fact(a,b-1)+fact(a-b,b);
}
main()
{
int t,M,N;
scanf("%d",&t);
while(t--)
{
     scanf("%d %d",&M,&N);
   printf("%d\n",fact(M,N));
}

}


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

}

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

}


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

int put(int apple,int plate)
{
   if(plate==1 || apple==1) return 1;
   if(apple<plate) return put(apple,apple);
   if(apple==plate) return put(apple,plate-1)+1;
   return put(apple-plate,plate)+put(apple,plate-1);
}


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

int app(int x,int y)
{
    if(x<y&&y!=1)
    {
         return app(x,y-1);
    }
    else if(y==1)
    {
         return 1;
    }
    else
    {
         return (app(x,y-1)+app(x-y,y));
    }
}


int t,m,n;
int K(int a,int b,int c)
{
	int count=0;
	if (a==n-1&&b<=c)
		return 1;
	for (int i=b;i<=(c/(n-a));i++)
		count+=K(a+1,i,c-i);
	return count;
}
int main()
{
	cin>>t;
	for(int i=1;i<=t;++i){
		cin>>m>>n;
	cout<<K(0,0,m)<<endl;
	}
	return 0;
}


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


int digui(int x,int y)

{

       int z;

       if(x==1||x==0)
        z=1;
       else if(y==1) z=1;
       else if(x>=y) z=digui(x-y,y)+digui(x,y-1);
       else z=digui(x,x);
       return z;

}

int main()

{

       int t,n,m;

       scanf("%d",&t);

       while(t--)

       {

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

              printf("%d\n",digui(m,n));

       }

       return 0;

}


/*
 * ParallelResistance.cpp
 *
 *  Created on: 2011-9-21
 *      Author: 1100012959
 */

int sol(int apple,int plate)//?????????
{
	int solution;//???????
	if(plate==1||apple==0)//??????????1?????0
		solution=1;//??????
	else if(apple>=plate)//???????????
	{
		solution=sol(apple-plate,plate)+sol(apple,plate-1);//????????????????????
	}
	else if(apple<plate) solution=sol(apple,plate-1);//?????????????????
	return solution;
}
int main()
{
	int n,apple,plate,solution;
	cin>>n;
	for(;n>0;n--)//????
	{
		cin>>apple>>plate;
		solution=sol(apple,plate);
		cout<<solution<<endl;
	}
	return 0;
}


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


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


int main()
{
	int find(int,int);
	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)
{
//	printf("%d %d\n",m,n);
	if (m==1 || m==0) return (1);
	else if (n==1) return (1);
		else
			if (m>=n) return (find(m-n,n)+find(m,n-1));
			else return (find(m,n-1));
}


/*
 * 4.cpp
 *
 *  Created on: 2010-11-30
 *      Author: ???
 *        ??? ???
 */

int k(int m,int n){
	if(n==1)
		return 1;
	if(m>=n)
		return k(m-n,n)+k(m,n-1);
	else
		return k(m,n-1);
}

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


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


int type(int m,int n)
{int c;
	if(m==1||n==1)
c=1;
else if(m==0||n==0)
	c=1;
else if(m<n)
	c=type(m,m);
else
	c=type(m,n-1)+type(m-n,n);
return(c);}
int main()
{int type(int m,int n);
	int t,M[20],N[20],i;

	scanf("%d",&t);
for(i=0;i<t;i++)
scanf("%d%d",&M[i],&N[i]);
for(i=0;i<t;i++)
printf("%d\n",type(M[i],N[i]));
return 0;
}


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

  return 0;
}
void Divide(int n,int m,int s )
{
  if(s>=1)
  {
  for(int i=s;i>=1;i--)
  {   if(n-i==0)
     {
      counter+=1;
     }
      else if(n-i>0&&m-1>0)
      Divide(n-i,m-1,i);
  }
  }
}


int all(int m,int n)
{
    int empty(int m,int n);
    int noempty(int m,int n);
    int sum;
    sum=empty(m,n)+noempty(m,n);
    return(sum);
}
int empty(int m,int n)
{
    int s1;
    if(n==1)
    s1=0;
    else
    s1=all(m,n-1);
    return(s1);
    }
int noempty(int m,int n)
{
    int s2;
    if(m-n<0)
    s2=0;
    else if(m-n==0)
    s2=1;
    else
    s2=all(m-n,n);
    return(s2);
}
int main()
{
    int m,n,i,t,a[100],b[100];
    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",all(a[i],b[i]));
     }
return 0;
}


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


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

}


int B(int,int);
int main()
{
	int t,m,n;
	cin>>t;
	for(int i=0;i<t;++i)
	{
		cin>>m>>n;
		int sum=0;
		for(int j=1;j<=n;++j)
			sum+=B(m,j);
		cout<<sum<<'\n';
	}
	return 0;
}

int B(int n,int k)
{
	if(k==1||n==k)
		return 1;
	else
	{
		if(k>n) return 0;
		else{
			int result=0;
			for(int l=k;l>0;--l)
				result+=B(n-k,l);
			return result;
		}
	}
}


int c(int m, int n)
{
	int s1, s2, k = m;
	s1 = s2 = 1;
	while (k--)
	{
		s1 *= n--;
		s2 *= m--;
		//cout << s1 << ' ' << s2 << endl;
	}
	return s1 / s2;
}

int f(int m, int n)
{
	if (n == 1)
		return 1;
	//if (m == 0)
		//return 1;
	if (m < n)
	{
		return f(m, n - 1);
	}

	return f(m, n - 1) + f(m - n, n);
}

int main()
{
	int t;
	cin >> t;
	//cout << c(5, 3);
	//c(3, 5);

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


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


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


int a=0;
int fang(int m,int n)
{
    if (n==1)
	   a=1;
    if (m==0);
       a=1;
	if ((m<n)&&(n>1))
	   a=fang(m,n-1);
	if ((m>=n)&&(n>1))
       a=fang(m,n-1)+fang(m-n,n);
	//cout<<a;
   return (a);
}
int main()
{
    int t,i;
	cin>>t;
	for (i=0;i<t;i++)
	{
       int m,n;
	   cin>>m>>n;
	   cout<<fang(m,n)<<endl;
	}
    return 0;
}


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


int num(int m, int n)
{
 if(m <= 1) return 1;
 if(n == 1) return 1;
 int sum = 0, i;
 for(i = 1; i <= n; i++)
 {
  if(i > m) break;
  sum += num(m - i, i);
 }
 return sum;
}
int main()
{
 int n, i;
 scanf("%d", &n);
 for(i = 0; i < n; i++)
 {
  int M, N;
  scanf("%d%d", &M, &N);
  int r = num(M, N);
  printf("%d\n", r);
 }
 return 0;
}


int main()
{
	int he(int p,int q);
	int t,m,n;
	int i,sum;
	scanf("%d",&t);
	for(i=0;i<t;i++)
	{
		scanf("%d %d",&m,&n);
		sum=he(m,n);
		printf("%d\n",sum);
	}
	return 0;
}
int he(int p,int q)
{
	int kong(int a,int b);
	int man(int c,int d);
	int h;
	if(q==1) h=1;
	else h=kong(p,q)+man(p,q);
	return h;
}
int kong(int a,int b)
{
	int he(int p,int q);
	int e;
	if(b==1) e=1;
	else
	{
		e=he(a,b-1);
	}
	return e;
}
int man(int c,int d)
{
	int he(int p,int q);
	int f;
	if(c<d) f=0;
	else if(d==1) f=1;
	else f=he(c-d,d);
	return f;
}


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

    return 0;
}