#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)]
x = [int(input()) for i in range(N)]
# max = 20000
# if N > max: N = max
all = ""
i = 0
drop = 0
xxor = 0
while i < N:
xx = x[i]
#aa = xx % 4
aa = xx & 3
if aa == 0 : xxor = xx
if aa == 1 : xxor = 1
if aa == 2 : xxor = xx + 1
if aa == 3 : xxor = 0
drop = xxor
m = mm
for index in range(30):
if m ^ drop <= xx:
drop ^= m
m >>= 1
#print(xxor, xxor ^ drop, flush=True)
all = all + str(xxor) + " " + str(xxor ^ drop) + "\n"
# sys.stdout.write(str(xxor) + " " + str(xxor ^ drop) + "\n")
i += 1
#sys.stdout.write(all)
print(all)