Pagini recente » Cod sursa (job #2652441) | Cod sursa (job #2999523) | Cod sursa (job #3182425) | Cod sursa (job #2520408) | Cod sursa (job #860695)
Cod sursa(job #860695)
var p,b,x,min,t,i:integer;
f,g:text;
begin
assign(f,'fructe.in');reset(f);
assign(g,'fructe.out');rewrite(g);
read(f,t);
for i:=1 to t do begin
read(f,p);
read(f,b);
repeat
if p>0 then begin p:=p-1; b:=b-1; b:=b+1; end;
if b>=2 then begin b:=b-2; p:=p+1; end;
until ((p=1) and (b=0)) or ((p=0) and (b=1));
if p=1 then writeln(g,0)
else writeln(g,1);
end;
close(f);
close(g);
end.