var
a,b,c,n:longint;
begin
assign (input, 'ROOK.IN');
reset(input);
read(n);
while 1<=n do begin
read(a,b);
if a >= b then write('2');
if a < b then write('1');
if (a=1) and (b=1) then c:=0;
writeln(c);
dec(n);
end;
end.