program z318_2; {$APPTYPE CONSOLE} var t,j:integer; i, k,n:int64; r:extended; begin readln(t); for j:=1 to t do begin readln(n,k); if k>n div 2 then k:=n-k; r:=1; i:=n; while i>n-k do begin if (n-i+1)>1 then r:=r*i/(n-i+1) else r:=r*i; dec(i); end; writeln(r:0:0); end; end.