import java.util.Scanner;
public class Main {
static long[][] arr;
static long combination(int m, int n) {
if(arr[m][n] != 0) {
return arr[m][n];
}
if(m ==n || n == 0) {
return 1;
}
arr[m][n] = combination(m-1, n-1) + combination(m-1, n);
return arr[m][n];
}
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
StringBuilder sb = new StringBuilder();
int T = kb.nextInt();
for(int i=0; i<T; i++) {
int n = kb.nextInt();
int m = kb.nextInt();
arr = new long[m+1][n+1];
sb.append(combination(m,n)+"\n");
}
System.out.println(sb);
}
}