Pagini recente » Cod sursa (job #1755562) | Cod sursa (job #2212061) | Cod sursa (job #1623844) | Cod sursa (job #441630) | Cod sursa (job #866852)
Cod sursa(job #866852)
var f,g:text;
p,b,ps,bs,k,t,pss:integer;
begin
assign(f,'fructe.in');reset(f);
assign(g,'fructe.out');rewrite(g);
readln(f,t);
repeat
k:=k+1;
read(f,p);
readln(f,b);
ps:=p;
bs:=b;
while (ps<>0) and (bs<>0) do
begin
pss:=ps;
if (ps=1) and (bs=1) then
begin
bs:=1;
ps:=0;
break;
end;
if bs mod 2=0 then
begin
bs:=0;
break;
end
else
begin
ps:=ps mod 2+ pss div 2+bs div 2;
bs:=1;
end;
end;
if ps=1 then writeln(g,0);
if bs=1 then writeln(g,1);
until k=t;
close(f);
close(g);
end.