#include
using namespace std;
int main(){
int t;
cin>>t;
while(t–){
long long int n,m,ans;
ans=1;
cin>>n>>m;
n=n-1;
m=m-1;
if(n-m<m){
m=n-m;
}
int x=1;
for(long long int i=n;i>m;i-- ){
ans=ans*(i);
ans=ans/x;
x++;
}
cout<<ans<<endl;
}
}