#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll C(ll n, ll m){
ll c;
if(n < m) return 0;
else if(m == 0) return 1;
else{
c = 1;
n = n - m + 1;
for(int i = 1; i <= m; i++){
c *= n++;
c /= i;
}
}
return c;
}
int main(){
#ifdef ONLINE_JUDGE
#else
freopen("in.txt", "r", stdin);
#endif
int t, n, m;
scanf("%d", &t);
while(t--){
scanf("%d%d", &n, &m);
printf("%lld
", C(n, m));
}
return 0;
}