from sys import stdin, stdout
import sys
import os
pow2 = [1 << i for i in range(30)][::-1]
mm = pow2[0]
N = int(input())
x = [int(stdin.readline()) for i in range(N)]
# max = 20000
# if N > max: N = max
all = ""
i = 0
while i < N:
xx = x[i]
aa = xx % 4
if aa == 0 : xor = xx
if aa == 1 : xor = 1
if aa == 2 : xor = xx + 1
if aa == 3 : xor = 0
drop = xor
m = mm
for index in range(30):
if m ^ drop <= xx:
drop ^= m
m >>= 1
print(xor, xor ^ drop, flush=True)
#all = all + str(xor) + " " + str(xor ^ drop) + "\n"
# sys.stdout.write(str(xor) + " " + str(xor ^ drop) + "\n")
i += 1
#sys.stdout.write(all)