cook your dish here
def fact(n):
res = 1;
for i in range(1,n+1):
res = res *i;
return res;
def nCr(n,k):
return (fact(n)/(fact(n-k) * fact(k)))
t = int(input());
while(t):
n, k = map(int, input().split())
print(int(nCr(n-1,k-1)));
t = t-1;