program C1128;
var n,i,a:longint;
temp:extended;
K:Qword;
begin
assign(input,'unlessseq.in');
reset(input);
assign(output,'unlessseq.out');
rewrite(output);
readln(n);
for i:=1 to n do begin
readln(a);
temp:=sqrt(1+a<<3);
if trunc(temp)=temp then K:=((trunc(temp)-1)>>1)
else K:=trunc((temp-1)/2)+1;
if a-K*(K-1)>>1=1 then writeln(1) else writeln(0);
end;
close(input);
close(output);
end.