{anti-arithmetic - starting with a small set build it up by splitting even and odd numbers} var o : array[1..15000] of integer; n : array [1..15000] of integer; {our set} f, f2 : text; i, j, cnt, x, NN : longint; function min(a, b : longint) : longint; begin if (a < b) then min:= a else min:= b; end; begin assign(f, 'arith.in'); reset(f); assign(f2, 'arith.out'); rewrite(f2); for i:= 1 to 15000 do begin o[i]:= -1; n[i]:= -1; end; o[1]:= 3; o[2]:= 1; o[3]:= 0; o[4]:= 2; cnt:= 2; for i:= 1 to 12 do begin cnt:= 2 * cnt; for j:= 1 to min(cnt, 15000 div 2) do begin n[2*j-1]:= o[j]; n[2*j]:= o[j] + cnt; end; move(n, o, sizeof(n) ); end; readln(f, NN); for i:= 1 to NN do begin readln(f, x); for j:= 1 to 14999 do if (n[j] <= x) and (n[j] > -1) then write(f2, n[j], ' '); if (n[15000] <= x) and (n[15000] > -1) then writeln(f2, n[j]); writeln(f2, ''); end; close(f); close(f2); end.