Problem:
 Score : 500 points    Problem Statement There are N Snuke Cats numbered 1, 2, \ldots, N , where N is even .  Each Snuke Cat wears a red scarf, on which his favorite non-negative integer is written.  Recently, they learned the operation called xor (exclusive OR).   What is xor?  For n non-negative integers x_1, x_2, \ldots, x_n , their xor, x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is defined as follows:  When x_1~\textrm{xor}~x_2~\textrm{xor}~\ldots~\textrm{xor}~x_n is written in base two, the digit in the 2^k 's place ( k \geq 0 ) is 1 if the number of integers among x_1, x_2, \ldots, x_n whose binary representations have 1 in the 2^k 's place is odd, and 0 if that count is even.  For example, 3~\textrm{xor}~5 = 6 .   They wanted to use this operation quickly, so each of them calculated the xor of the integers written on their scarfs except his scarf.  We know that the xor calculated by Snuke Cat i , that is, the xor of the integers written on the scarfs except the scarf of Snuke Cat i is a_i .
Using this information, restore the integer written on the scarf of each Snuke Cat.      Constraints  All values in input are integers.  2 \leq N \leq 200000  N is even .  0 \leq a_i \leq 10^9  There exists a combination of integers on the scarfs that is consistent with the given information.         Input Input is given from Standard Input in the following format:  N  a_1  a_2  \ldots  a_N       Output Print a line containing N integers separated with space.  The i -th of the integers from the left should represent the integer written on the scarf of Snuke Cat i .  If there are multiple possible solutions, you may print any of them.        Sample Input 1 4
20 11 9 24      Sample Output 1 26 5 7 22   5~\textrm{xor}~7~\textrm{xor}~22 = 20  26~\textrm{xor}~7~\textrm{xor}~22 = 11  26~\textrm{xor}~5~\textrm{xor}~22 = 9  26~\textrm{xor}~5~\textrm{xor}~7 = 24   Thus, this output is consistent with the given information.

Solution (Python):
n = int(input())
A = list(map(int,input().split()))
B = [0]*30
ans = []
for i in A:
    for j in range(30):
        if (i>>j) & 1:
            B[j] += 1
for i in A:
    C = [c for c in B]
    for j in range(30):
        if (i>>j) & 1:
            C[j] -= 1
    a = 0
    for j in range(30):
        if C[j]%2 == 1:
            a += 2**(j)
    ans.append(str(a))
print(" ".join(ans))

Solution (Python):
N = int(input())
a = [int(i) for i in input().split()]
ans = []
s = 0
for x in a:
    s = s^x
for x in a:
    ans.append(x^s)
print(*ans)

Solution (Python):
N=int(input())
a=list(map(int,input().split()))
b=a[0]
for i in range(N-1):
  b=b^a[i+1]
x=[0 for i in range(N)]
for i in range(N):
  x[i]=b^a[i]
x=map(str,x)
ans=' '.join(x)
print(ans)

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
c=[]
s=0
for i in range(n):
    s=s^a[i]
for i in range(n):
    c.append(s^a[i])
print(*c)

Solution (Python):
n = int(input())
A = list(map(int, input().split()))
l = [0]*50
for s in A:
    b = list(bin(s))
    b = b[::-1]
    for ii, ss in enumerate(b):
        if ss == "b":
            break
        if ss == "1":
            l[ii] = (l[ii]+1) % 2
e = 1
num = 0
for i in range(50):
    num += l[i]*e
    e = e*2
for s in A:
    print(s ^ num)

Solution (Python):
def constructXOR(A, n): 
      
    
    XOR = 0
    for i in range(0, n): 
        XOR ^= A[i] 
  
    
    for i in range(0, n): 
        A[i] = XOR ^ A[i] 

n = int(input())
A = list(map(int,input().split()))
constructXOR(A, n) 

for i in range(0,n): 
    print(A[i], end =" ")

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

b = [0 for i in range(n)]

A = 0

for i in range(n):
  A = A ^ a[i]
  
for i in range(n):
  b[i] = A ^ a[i]

print(' '.join(map(str, b)))

Solution (Python):
from functools import reduce
N = int(input())
A = [int(x) for x in input().split(" ")]

S = reduce(lambda a, b: a ^ b, A)
B = [str(a ^ S) for a in A]
print(" ".join(B))

Solution (Python):
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
a=ii()
l=list(mi())
x=[1]*31
y=[[] for _ in range(a)]
for i in range(a):
  for j in range(31):
    if l[i]>>j & 1:
      x[j]=x[j]*(-1)
      y[i].append(-1)
    else:
      y[i].append(1)
c=0
for k in range(a):
  co=0
  for j in range(31):
    if x[j]!=y[k][j]:
      co+=2**j
  print(co,end=' ')

Solution (Python):
import collections
N = int(input())
A = list(map(int,input().split()))
S = collections.deque([])
for i in range(1,N):
    S.append(A[i]^A[i-1])
val = A[0]
for i in range(0,len(S),2):
    val = val^S[i]
T = [str(val)]
while len(S)>0:
    T.append(str(int(T[-1])^S.popleft()))
print(' '.join(T))

Solution (Python):
N = int(input())
a_list = list(map(int, input().split()))

all_xor = a_list[0]
for i in a_list[1:]:
    all_xor ^= i

result = []
for i in a_list:
    result.append(all_xor ^ i)

print(*result)

Solution (Python):
import sys
import  math
import fractions
from collections import defaultdict
import heapq
from bisect import bisect_left,bisect

stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
A=nl()
keta=[0]*60
for i in A:
    for j in range(60):
        keta[j]+=((i>>j)&1)

ans_l=[0]*N
for i in range(N):
    for j in range(60):
        if(keta[j]%2!=(A[i]>>j)&1):
            ans_l[i]+=(1<<j)

print(*ans_l)

Solution (Python):
n = int(input())
a = list(map(int,input().split()))

c = 0
for i in range(1,n):
    c ^= a[i]
    
for i in range(n):
    k = a[0] ^ a[i]
    print(k^c)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]
axor = 0
for i in a:
   axor = axor ^ i
for i in a:
   print(axor ^ i)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
s = 0
for a in A:
    s ^= a
for a in A:
    print(s ^ a)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

b = [0 for i in range(n)]

A = 0

for i in range(n):
  A = A ^ a[i]
  
for i in range(n):
  b[i] = A ^ a[i]

print(' '.join(map(str, b)))

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, chain
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'


def main():
    N=ii()
    A = lmis()
    g = 0
    for a in A:
        g ^= a
    for a in A:
        print(g^a)



main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
allxor = a[0]
for i in range(1, n):
    allxor = allxor ^ a[i]
for i in a:
    print(allxor ^ i, end=' ')

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
b = [[] for _ in range(n)]
c = [0]*30
d = []
for i in range(n):
    m = a[i]
    while m > 0:
        b[i].append(m%2)
        m //= 2
for i in range(n):
    for j in range(len(b[i])):
        c[j] += b[i][j]
for i in range(30):
    c[i] = c[i]%2
for i in range(n):
    e = 0
    for j in range(len(b[i])):
        if b[i][j]+c[j] == 1:
            e += 2**j
    for j in range(len(b[i]), 30):
        if c[j] == 1:
            e += 2**j
    d.append(e)
print(*d)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

b = [0 for i in range(n)]

A = 0

for i in range(n):
  A = A ^ a[i]
  
for i in range(n):
  b[i] = A ^ a[i]

print(' '.join(map(str, b)))

Solution (Python):
import sys, math


if(__name__ == "__main__"):
    """

    元の数biを求めるにはxor_all= a1^a2^a3^...^an
    を求め、
    b1=xor_all^a1, b2 = xor_all^a2, ...とする。Nが偶数なので
    xor_all = b1^b2^...^bnと等しい(xorの性質よりx^a^a = xとなるので)
    xor_allにaiをかけるとちょうどbiだけ残る
    """
    N = int( input().strip() )
    xors = [0] * N
    Str = input().strip().split()
    for i in range(N):
        xors[i] = int( Str[i] )
    xor_all = xors[0]
    for i in range(1, N):
        xor_all = xor_all ^ xors[i]
    nums = [0] * N

    Str = ""
    for i in range(N):
        nums[i] = xor_all^xors[i]
        Str += str(nums[i]) + " "
    
    print(Str)

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from collections import defaultdict

N = int(input())  
A = list(map(int, input().split()))
xorA = A[0]
for i in range(1, N):
    xorA = xorA ^ A[i]

ans = []
for i in range(N):
    res = xorA ^ A[i]
    res = int(res)
    ans.append(str(res))

print(" ".join(ans))

Solution (Python):
n=int(input())
a=input().split()
nl=[]
jo=0
for i in range(n):
  nl.append(int(a[i]))
  jo=jo^int(a[i])

for i in range(n):
  ans=nl[i]^jo
  print(ans,end=" ")
print("")

Solution (Python):
import numpy as np
def resolve():
    N = int(input())
    A = np.array(list(map(int, input().split())))
    ans = ""

    for n in range(len(bin(max(A))) - 1, -1 ,-1 ):
        ans += str(np.count_nonzero((A >> n)&1) % 2)
    for i in range(N):
        print(int(ans,2) ^ A[i], end =" ")
resolve()

Solution (Python):
n  = int(input())
a = [int(x) for x in input().split()]
s = a[0]
for i in range(1, n):
    s = s ^ a[i]

ans = []
for x in a:
    ans.append(s ^ x)
print(*ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

Aall = 0  
for i in range(N):
  Aall ^= A[i]

ans = ""
for i in range(N):
  ans += str( Aall ^ A[i] ) + " "

print(ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
num = 30
list_a = [[0]*num for i in range(n)]
list_ans = []
for i in range(n):
    count = 0
    j = a[i]
    while j>0:
        list_a[i][count]=j%2
        j = j//2
        count+=1
list_sum = []
for i in range(num):
    su = 0
    for j in range(n):
        su+=list_a[j][i]
    list_sum.append(su%2+2)
for i in range(n):
    ans = 0
    for j in range(num):
        k = list_sum[j]
        list_a[i][j] -=list_sum[j]
        list_a[i][j]%=2
for i in range(n):
    wa = 0
    for j in range(num):
        wa+= (list_a[i][j]*pow(2,j))
    list_ans.append(wa)
print(" ".join(map(str,list_ans)))

Solution (Python):
def main():
    n = int(input())
    a = list(map(int,input().split()))
    
    tot = 0
    for i in range(n):
        tot ^= a[i]
    res = [0]*n
    for i in range(n):
        res[i] = tot ^ a[i]
    print(*res)

if __name__ == '__main__':
    main()

Solution (Python):
def main():
    _ = int(input())
    A = list(map(int, input().split()))

    allXOR = 0
    for a in A:
        allXOR = allXOR ^ a  

    R = []
    for a in A:
        R.append(a ^ allXOR)

    print(*R)


if __name__ == '__main__':
    main()

Solution (Python):
from collections import deque
from functools import reduce
n = int(input())
al = [int(i) for i in input().split()]
ad = deque(al)

num = reduce(lambda x, y: x ^ y, al)

num = num ^ al[0]
print(num)
pre = al[0]
for i in al[1:]:
  num = num ^ pre
  num = num ^ i
  print(num)
  pre = i

Solution (Python):
n= int(input())
l= list(map(int, input().split()))

tot=0
for num in l:
	tot^= num

ans=[]

for num in l:
	ans.append(num^tot)

print(*ans)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))

xor = 0
for i in range(N):
  xor = xor ^ a[i]
  
ans = []
  
for i in range(N):
  ans.append(xor ^ a[i])
  
print(' '.join(map(str, ans)))

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
ans = []
s = 0
for i in range(N):
    s = s ^ a[i]

for i in range(N):
    tmp = s ^ a[i]
    ans.append(str(tmp))
    
ans = ' '.join(ans)    
print(ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
b = 0
C = []

for a in A:
  b^=a

for a in A:
  C.append(a^b)

print(*C)

Solution (Python):
n = int(input())
alist = [int(s) for s in input().split(" ")]
asum = alist[0]
for a in alist[1:]:
  asum ^= a

import copy
a_ans = []
for i in range(n):
  asum ^= alist[i]
  a_ans.append(asum)
  asum ^= alist[i]
print(" ".join([str(a) for a in a_ans]))

Solution (Python):
n = int(input())
data = list(map(int, input().split()))
total = 0
for a in data:
    total ^= a
ans = [total^a for a in data]
print(' '.join(map(str, ans)))

Solution (Python):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_list(N): return [s_list() for _ in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    num_list = i_list()

    sum_d = 0
    for num in num_list:
        sum_d ^= num

    ans_list = []
    for num in num_list:
        ans_list.append(sum_d ^ num)

    print(*ans_list)

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input().strip()) 
a = [int(x.strip()) for x in input().strip().split(' ')]

t = 0
for i in a:
  t = t ^ i

b = []
for i in a:
  b.append(str(t ^ i))
print(' '.join(b))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

l = 0
for i in a:
  l ^= i

for i in a:
  j = l ^ i
  print(j, end=' ')

Solution (Python):
_,*a = open(0).read().split()
x = eval("^".join(a))
for i in a:
    print(x^int(i),end=" ")

Solution (Python):
import glob
import os

bn = os.path.basename(__file__).split('.')[0]
dn = os.path.dirname(__file__).split('/')


REL_PATH = dn[len(dn)-2] + '\\' + dn[len(dn)-1] + '\\' + bn


TOP_PATH = 'C:\\AtCoder'

class Common:
    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index - 1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        N = int(self.input_data())
        a = list(map(int, self.input_data().split()))

        a2_sum = [0]*N

        for i in range(0, N, 2):
            a2_sum[i] = a[i] ^ a[i+1]

        source = 0
        for i in range(0, N, 2):
            source = source ^ a2_sum[i]

        for i in range(N):
            print(str(a[i]^source), end=' ')


solver = Solver(REL_PATH)
solver.exec_resolve()

Solution (Python):
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
k = len(bin(np.max(a)))-2

b = []
c = [0] * k
for aa in a:
    d = bin(aa)[2:]
    e = k-len(d)
    for i in range(len(d)):
        if d[i] == '1':
            c[e+i] += 1

xo = int(''.join(['1' if c[i] % 2 == 1 else '0' for i in range(k)]), 2)

print(' '.join(map(str, (a ^ xo))))

Solution (Python):
N = int(input())
A = list(map(int, input().split()))

AA = [0] * (N)
for i in range(N):
    AA[i] = list(format(A[i], 'b').zfill(42))

ans = [0] * 42
ma = 0
for i in range(N):
    AA[i].reverse()
    for j in range(len(AA[i])):
        ma = max(ma, j)
        ans[j] += int(AA[i][j])

ret = []
for i in range(N):
    temp = 0
    for j in range(ma):
        if (ans[j] + int(AA[i][j])) & 1 == 1:
            temp += 1 << j

    ret.append(temp)

print(*ret)

Solution (Python):
N = int(input())
a = [int(x) for x in input().split()]

ans = a[0]
for i in range(1, N):
    ans = ans ^ a[i]

res = [0 for _ in range(N)]
for i in range(N):
    res[i] = ans ^ a[i]
    res[i] = str(res[i])

print(' '.join(res))

Solution (Python):

n = int(input())
a = list(map(int, input().split()))
dp = [0] * 31
ans = []

for i in a:
    num = format(i, 'b').zfill(31)
    for j in range(31):
        if num[j] == '1':
            dp[j] += 1

for i in a:
    x = 0
    num = format(i , 'b').zfill(31)
    for j in range(31):
        if int(dp[j] - int(num[j])) % 2 == 0:
            continue
        elif int(dp[j] - int(num[j])) % 2 == 1:
            x += 2 ** (30 - j)
    ans.append(x)

for i in ans:
    print(i, end=' ')

Solution (Python):
n = int(input())
al = list(map(int, input().split()))
zen = al[0]
for i, a in enumerate(al):
    if i == 0:
        pass
    else:
        zen ^= a

print(*[a ^ zen for a in al])

Solution (Python):
N = int(input())
A = list(map(int,input().split()))
k = A[0]
m = 0
for i in range(1, N):
    k = k^A[i]
for i in range(N):
    A[i] = A[i]^k
print(" ".join([str(n) for n in A]))

Solution (Python):
import sys
readline = sys.stdin.readline


def main():
    N = int(readline())  
    A = list(map(int, readline().rstrip().split()))  
    
    if N == 2:
        print(*A[::-1])
        return
    
    xor = []
    for i in range(N-1):
        xor.append(A[i] ^ A[i+1])  
    
    
    b = A[0]
    for i in range(2, N, 2):
        b ^= xor[i]
    
    
    a = xor[0] ^ b

    
    res = [a, b]
    pre = b

    
    for x in xor[1:]:
        next = pre ^ x
        res.append(next)
        pre = next

    
    print(*res)


if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))

XOR=a[0]
for i in range(1,n):
    XOR^=a[i]

swt=format(XOR, '030b')

s=[]
for i in range(30):
    if swt[i]=="1":
        s.append(i)
        

ans=[]

for i in range(n):
    temp=list(format(a[i], '030b'))
    for i in s:
        if temp[i]=="1":
            temp[i]="0"
        else:
            temp[i]="1"
    
    ans.append(int("".join(temp),2))

print(' '.join([str(n) for n in ans]))

Solution (Python):
n = int(input())

x = list(map(int,input().split()))

ans=0

for i in range(1,n):
	ans^=x[i]
ans2=ans^x[0]
y=[]
y.append(str(ans))
for i in range(1,n):
	t=ans2^x[i]
	y.append(str(t))
print(' '.join(y))

Solution (Python):
n = int(input())
a = list(map(int, input().split()))
res = a[0]
for i in range(1, n):
    res ^= a[i]
ans = []
for i in range(n):
    ans.append(res^a[i])
print(*ans)

Solution (Python):
N = int(input())

A = list(map(int, input().split()))

temp = A[0]

for a in A[1:]:
    temp ^= a

print(*[a^temp for a in A])

Solution (Python):
import sys
import math as mt
input=sys.stdin.buffer.readline  

t=1
for __ in range(t):
    
    n=int(input())
    l=list(map(int,input().split()))
    xori=0
    for i in l:
        xori^=i
    for i in l:
        print(xori^i,end=" ")

Solution (Python):
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
S= 0
for n in range(N):
  S = S^A[n]
  
ans = ''
for n in range(N):
  m = S^A[n]
  ans += str(m) + ' '

print(ans[:-1])

Solution (Python):
n = int(input())
a = list(map(int,input().split()))
x = a[0]
for i in range(1,n):
    x = x^a[i]
res = []
for i in range(n):
    res.append(x^a[i])
print(*res)

Solution (Python):
N = int(input())
a = list(map(int,input().split()))

xor = a[0]
for i in range(1,N):
    xor = xor ^ a[i]

ans = []
for i in range(N):
    ans.append(xor ^ a[i])
print(*ans)

Solution (Python):
bitsum = 0
ans = []
N = int(input())
num = list(int(x) for x in input().split())
for i in num:
    bitsum = bitsum ^ i
for i in num:
    ans.append(bitsum ^ i)
print(' '.join(map(str, ans)))

Solution (Python):
import sys
from io import StringIO
import unittest
import os
from operator import ixor
from functools import reduce


sys.setrecursionlimit(999999999)



def resolve(test_def_name=""):
    
    
    
    
    
    

    
    
    
    n = int(input())
    x = list(map(int, input().split()))

    aaa = x[0]
    for cnt, i in enumerate(x):
        if cnt == 0:
            continue
        aaa = ixor(aaa, i)

    ans = []
    for cnt, i in enumerate(x):
        ans.append(ixor(aaa, i))

    print(*ans)


class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """4
20 11 9 24"""
        output = """26 5 7 22"""
        self.assertIO(test_input, output)

    
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)



if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        
        resolve()

    else:
        
        unittest.main()

Solution (Python):
N = int(input())

A = [int(_) for _ in input().split()]

s = 0
for a in A:
    s = s ^ a

ans = []
for a in A:
    ans.append(s ^ a)

print(" ".join(str(_) for _ in ans))

Solution (Python):
n = int(input())
A = [int(x) for x in input().split()]
a1 = A[1]
if n > 2:
    for an in A[2:]:
        a1 = a1 ^ an
a_all = A[0] ^ a1
ans = str(a1)
for an in A[1:]:
    ans += ' ' + str(a_all ^ an)
print(ans)

Solution (Python):
n = int(input())
a = [int(i) for i in input().split()]

sl = [0 for i in range(n+1)]
sr = [0 for i in range(n+1)]
ans = []

for i in range(1, n+1):
  sl[i] = sl[i-1] ^ a[i-1]
  sr[n-i] = sr[n-i+1] ^ a[n-i]

for i in range(n):
  ans.append(str(sl[i] ^ sr[i+1]))
  
print(" ".join(ans))

Solution (Python):
n = int(input())
ali = list(map(int, input().split()))

allxor = 0
for ai in ali:
    allxor = allxor ^ ai

for i in range(n):
    ans = allxor ^ ali[i]
    
    if i != (n-1):
        print(ans, end=" ")
    else:
        print(ans)

Solution (Python):
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

n = INT()
a = LIST()

res = 0
for i in range(n):
    res = res ^ a[i]

for i in range(n):
    print(res ^ a[i], end = " ")

Solution (Python):
N= int(input())
A= list(map(int, input().split()))
res = 0
for i in A:
    res = res ^ i

for i in A:
    print(res ^ i)

Solution (Python):

import numpy as np
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, input().split()))


def z():
    return int(input())


def S():
    return input()


def C(line):
    return [input() for _ in range(line)]


N = z()
a = zz()
ans = []
all_xor = 0
for _a in a:
    all_xor ^= _a

for i in range(N):
    tmp = -(all_xor ^ (~a[i])) - 1
    ans.append(tmp)
print(*ans)

Solution (Python):

import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline



n = int(input())
arr = list(map(int, input().split()))
ans = []
temp = 0
for i in arr:
	temp^=i
for i in range(n):
	ans.append(temp^arr[i])
print(*ans)

Solution (Python):
N = int(input())
A = list(map(int, input().split()))
Xsum = 0
for a in A:
    Xsum = Xsum^a
Ans = [Xsum^A[i] for i in range(N)]
print(" ".join(map(str, Ans)))

Solution (Python):
import math

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    N = ii()
    a = list(mi())
    t = a[0]
    for i in range(N-1):
        t ^= a[i+1]

    l = [t^a[i] for i in range(N)]
    print(' '.join(list(map(str, l))))
    


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

ma = max(a)
tmp = 1
m = 0
while True:
    if tmp >= ma:
        break
    tmp *= 2
    m += 1

memo = [0 for i in range(m+1)]

for j in range(m+1):
    cnt0 = 0
    cnt1 = 0
    for ai in a:
        if ai & (1 << j):
            cnt1 += 1
        else:
            cnt0 += 1
    if cnt1 % 2 == 0 and cnt0 % 2 == 0:
        memo[j] = 1

ans = []


for ai in a:
    ansi = 0
    for j in range(m+1):
        if ai & (1 << j):
            if memo[j]:
                ansi += 2 ** j
        else:
            if memo[j] == 0:
                ansi += 2 ** j

    ans.append(str(ansi))

print(" ".join(ans))

Solution (Python):

from collections import defaultdict
from sys import stdout
n=int(input())
l=list(map(int,input().split()))
x=l[0]^l[1]
for i in range(2,n):
  x^=l[i]
for i in range(n):
  stdout.write(str(x^l[i])+' ')

Solution (Python):
N = int(input())
A_list = [int(e) for e in input().split()]

all_A_xor = A_list[0]


for i in range(1,N):
    
    all_A_xor ^= A_list[i]



ans = [A^all_A_xor for A in A_list]
print(' '.join(map(str, ans)))

Solution (Python):
N = int(input())
AN= list(map(int, input().split()))

all = AN[0]
for i in range(N-1):
    all = all ^ AN[i+1]

output = []
for A in AN:
    output.append(str(A ^ all))
print(" ".join(output))

Solution (Python):
n = int(input())
a = list(map(int, input().split())) 
s = 0
ans = [0]*n
for i in range(0,n):
    s = s ^ a[i]
for i in range(0,n):
    ans[i] = s ^ a[i]
for  item in ans:
    print(item,end=' ')

Solution (Python):


N = int(input())
A = list(map(int,input().split()))
C = [format(i,'b') for i in A]



length = 0
for i in range(N):
    length = max(length, len(C[i]))




even = [True] * 31 
for i in range(N):
    pivot = C[i]
    char = []
    for j in range(len(pivot)):
        char.append(pivot[j])
    char = char[::-1]
    for j in range(len(char)):
        if(char[j] == '1'):
            even[j] = not(even[j])
    
    






for i in range(N):
    pivot = C[i]
    ret = []
    
    for j in range(length - len(pivot)):
        ret.append('0')
    for j in range(len(pivot)):
        ret.append(pivot[j])
    C[i] = (''.join(ret))
    









ans = []
for i in range(N):
    ret = []
    pivot = C[i]
    pivot = pivot[::-1]
    for j in range(length):
        if(even[j]):
            ret.append(pivot[j])
        else:
            if(pivot[j] == '0'):
                ret.append('1')
            else:
                ret.append('0')
    ret = ret[::-1]
    
    ans.append(int(''.join(ret), 2))
    


for i in range(N):
    print(ans[i], end=' ')
print()

Solution (Python):
N=int(input())
A=list(map(int, input().split()))

ans= [0]*N
tmp = A[1]

for i in range(2,N):
    tmp = tmp^A[i]

ans[0]=tmp
print(ans[0])

for i in range(1,N):
    ans[i]=ans[i-1]^A[i-1]^A[i]
    print(ans[i])

Solution (Python):


N=int(input())
a=list(map(int,input().split()))
b=[0]*N
for i in range(N-1):
    b[i]=a[i]^a[i+1]
b[-1]=a[-1]^a[0]


ans=[0]*N
for i in range(1,N):
    ans[0] ^=a[i]
for i in range(1,N):
    ans[i]= ans[i-1]^b[i-1]

print(*ans)

Solution (Python):
n = int(input())
a = list(map(int, input().split()))

res = a[0]
for i in range(1, n):
    res ^= a[i]

ans = []
for i in range(n):
    ans.append(res ^ a[i])

print(*ans)

Solution (Python):
N = int(input())
A = list(map(int,input().split()))

mm = 0
for i in A:
    mm = mm^i

for i in range(N):
    mm = mm^A[i]
    print("{} ".format(mm), end="")
    mm = mm^A[i]

print()

Solution (Python):
n=int(input())
a=list(map(int,input().split()))
num=a[0]
for i in range(1,n):
    num=num^a[i]
b=[]
for i in range(n):
    b.append(num^a[i])
print(' '.join(map(str, b)))

Solution (Python):
N = int(input())

def convert(x):
    return bin(int(x))

A = list(map(int, input().split()))

k = 0
for a in A:
    k = k ^ a

for a in A:
    print(int(k ^ a))

Solution (Python):
n=int(input())
aa=list(map(int,input().split()))
sup=0
ans=[]
for i in aa:
  sup=sup^i
for a in aa:
  ans.append(a^sup)
print(*ans)

Solution (Python):
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N,*A = map(int, read().split())
    
    L = [A[0]]
    R = deque([A[-1]])

    for i in range(1,N):
        L.append(L[-1] ^ A[i])
        R.appendleft(R[0] ^ A[-(i+1)])

    ans = [R[1]]
    for i in range(1,N-1):
        ans.append(L[i-1] ^ R[i+1])
    ans.append(L[-2])

    print(*ans)



if __name__ == "__main__":
    main()

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
L=lmp()
l=[0]*n
ans=[0]*n
for i in range(n-1):
    l[i]=L[i]^L[i+1]
l[n-1]=L[n-1]^L[0]

if n==2:
    print(L[1],L[0])
    exit()
abc=L[3]
for i in range(4,n):
    abc=abc^L[i]
ans[0]=abc^l[1]
for i in range(1,n):
    ans[i]=ans[i-1]^l[i-1]
print(*ans)

Solution (Python):
N = int(input())
a = list(map(int, input().split()))
s = a[0]
for i in range(1, N):
   s = s ^ a[i]

print(' '.join([ str(s ^ a[i]) for i in range(N)]))

Solution (Python):
N = int(input())
a = [int(_) for _ in input().split()]

xor = a[0]
for i in range(1, N):
  xor = xor ^ a[i]

ans = []
for b in a:
  ans.append(xor ^ b)
print(*ans)