poj1644
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;
set<vector<int> > se;
int f(int m,int n,vector<int> v){
if(m==0){
sort(v.begin(),v.end());
if(se.find(v)!=se.end()){
return 0;
}else{
se.insert(v);
return 1;
}
}
if(n<=0)return 0;
int ans = 0;
for(int i = 1; i <= m; i++){
v.push_back(i);
ans += f(m-i,n-1,v);
v.pop_back();
}
return ans;
}
int mem[50][50];
int f1(int m,int n){
if(mem[m][n])return mem[m][n];
if(m==1||n==1){
mem[m][n] =1;
return 1;
}
if(m==n){
mem[m][n] = f1(m,n-1)+1;
return mem[m][n];
}
else if(m>n){
mem[m][n] = f1(m,n-1)+f1(m-n,n);
return mem[m][n];
}
else if(m<n){
mem[m][n] = f1(m,m);
return mem[m][n];
}
}/*
int f2(){
if(m==1||n==1)return 1;
if(m==n)return 1+f1(m,n-1);
else if(m>n) return f1(m,n-1)+f1(m-n,n);
else if(m<n) return f1(m,m);
}*/
int main()
{
int n,m,t;
scanf("%d",&t);
while(t--){
vector<int>v;
scanf("%d%d",&m,&n);
// se.clear();
// printf("%d\n",f(m,n,v));
printf("%d\n",f1(m,n));
}
return 0;
}