import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws Exception { /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int num_tests = Integer.parseInt(br.readLine()); for(int print = 0; print < num_tests; print++){ String line = br.readLine(); String s[]=line.split(" "); int n = Integer.parseInt(s[0].trim()); int k = Integer.parseInt(s[1].trim()); System.out.println(combOfK(n, k)); } } public static int combOfK(int n, int k) { if (k == 1) { return n; } else if (k == n) { return 1; } else if (k > n) { return 0; }else{ return calc(n, k); } } private static Map<String, Integer> map = new HashMap<String, Integer>(); public static int calc(int n, int k){ if (k > n) { return 0; } if (k == 1) { return n; } String mapKey = n + "_" + k; Integer mapVal = map.get(mapKey); if (mapVal != null) { return mapVal; } int val = 0; for (int i=1; i<=n; i++) { val += calc(n-i-1, k-1); } map.put(mapKey, val); return val; } }