import java.io.*; import java.math.*; import java.util.*; class Gladiator_mg { static BigInteger[][] tab = new BigInteger[100][100]; static StreamTokenizer input = null; static BigInteger[]b = new BigInteger[200]; static int getInt() throws IOException { if (input == null) { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); input = new StreamTokenizer(br); } input.nextToken(); return (int)(input.nval+0.01); } static BigInteger glad(int n, int k) { if (k == 1) return BigInteger.ONE; else if (n < k || k< 1) return BigInteger.ZERO; else if(tab[n][k] != null) return tab[n][k]; else { return (tab[n][k] = glad(n-1, k).multiply(b[k]).add(glad(n-1, k-1).multiply(b[2*n-k]))); } } public static void main(String[] args) throws IOException { for (int i = 0; i < 200; ++i) b[i] = BigInteger.valueOf(i); int m =getInt(); for (int i = 0; i < m; ++i) { int n = getInt(); int k = getInt(); System.out.println(glad(n,k)); } } }