import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { long c; public static void main(String[] args) throws IOException{ /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */ BufferedReader in=new BufferedReader (new InputStreamReader (System.in)); String s=in.readLine(); String[] st= new String [10]; long n=Long.parseLong(s); long[] ele =new long[10]; long ans=0; for (int i=0;i<n;i++){ s=in.readLine(); st=s.split(" "); ele[0]=Long.parseLong(st[0]); ele[1]=Long.parseLong(st[1]); long diff=ele[0]-ele[1]+1; if(diff>=ele[1]){ ans= fact(diff)/(fact(ele[1])*fact(diff-ele[1]));} else { ans=0;} System.out.println(ans); } } public static long fact(long a){ if (a==0){return 1;} else { return a*fact(a-1); } } }