var
x:array[1..9] of integer;
i,t:byte;
p:text;
s,k,l:integer;
begin
assign(p,'pc.in');
reset(p);
readln(p,t);
for i:=1 to t do read(p,x[i]);
close(p);
assign(p,'pc.out');
rewrite(p);
for i:=1 to t do begin
for k:=1 to sqr(x[i]) do begin
if sqr(x[i])=s then break;
s:=0;
l:=k;
for l:=l to sqr(x[i])-1 do begin
s+=l;
if sqr(x[i])=s then break;
end;
end;
if sqr(x[i])<>s then write(p,'0 ') else write(p,'1 ');
end;
close(p);
end.