var
a,b,c,d,e,f,i,j,n:longint;
x,y:array[0..100]of longint;
k:array[0..100,0..100]of qword;
begin
assign(input,'piggy.in');
assign(output,'piggy.out');
reset(input);
rewrite(output);
readln(n);
for a:=1 to n do
readln(x[a],y[a]);
for a:=1 to 100 do
begin
k[a,a]:=1;
k[a,1]:=1;
end;
for j:=2 to 25 do
for i:=j+1 to 25 do
k[i,j]:=k[i-1,j]*j+k[i-1,j-1];
for a:=1 to n do
writeln(k[x[a],y[a]]);
close(input);
close(output);
end.