You are given two integer sequences, each of length N: a_1, ..., a_N and b_1, ..., b_N.
There are N^2 ways to choose two integers i and j such that 1 \leq i, j \leq N. For each of these N^2 pairs, we will compute a_i + b_j and write it on a sheet of paper.
That is, we will write N^2 integers in total.
Compute the XOR of these N^2 integers.
Definition of XOR
The XOR of integers c_1, c_2, ..., c_m is defined as follows:
 - Let the XOR be X. In the binary representation of X, the digit in the 2^k's place (0 \leq k; k is an integer) is 1 if there are an odd number of integers among c_1, c_2, ...c_m whose binary representation has 1 in the 2^k's place, and 0 if that number is even.
For example, let us compute the XOR of 3 and 5. The binary representation of 3 is 011, and the binary representation of 5 is 101, thus the XOR has the binary representation 110, that is, the XOR is 6.

-----Constraints-----
 - All input values are integers.
 - 1 \leq N \leq 200,000
 - 0 \leq a_i, b_i < 2^{28}

-----Input-----
Input is given from Standard Input in the following format:
N
a_1 a_2 ... a_N
b_1 b_2 ... b_N

-----Output-----
Print the result of the computation.

-----Sample Input-----
2
1 2
3 4

-----Sample Output-----
2

On the sheet, the following four integers will be written: 4(1+3), 5(1+4), 5(2+3) and 6(2+4).

Difficulty: competition

Starter code:

Solutions:
#!/usr/bin/env python3

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    ans = 0
    for k in range(30):
        C = [x & ((1 << (k+1)) - 1) for x in A]
        D = [x & ((1 << (k+1)) - 1) for x in B]
        C.sort()
        D.sort()
        # print(f'k = {k}')
        # print(f'C = {C}')
        # print(f'D = {D}')
        p, q, r = 0, 0, 0
        for i in range(N-1, -1, -1):
            while p < N:
                if C[i] + D[p] >= 1 << k: break
                p += 1
            while q < N:
                if C[i] + D[q] >= 2 << k: break
                q += 1
            while r < N:
                if C[i] + D[r] >= 3 << k: break
                r += 1
            x = ((q - p) + (N - r)) % 2
            # print(p, q, r, x)
            ans = ans ^ (x << k)
    print(ans)

main()


import bisect

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

ans = 0
for i in range(29):
    div_ = pow(2, i+1)
    A_tmp = sorted([x%div_ for x in A])
    B_tmp = sorted([x%div_ for x in B])
    cnt = 0
    tmp = pow(2, i)
    idx1 = N
    idx2 = N
    idx3 = N
    for a in A_tmp:
        while idx2>0 and B_tmp[idx2-1]>=2*tmp-a:
            idx2 -= 1
        while idx1>0 and B_tmp[idx1-1]>=tmp-a:
            idx1 -= 1
        while idx3>0 and B_tmp[idx3-1]>=3*tmp-a:
            idx3 -= 1
        cnt += ((idx2-idx1)+(N-idx3))%2
    if cnt % 2 == 1:
        ans += tmp
print(ans)


N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]

def xor(L):
    a = 0
    for l in L: a ^= l
    return a

def chk(L1, L2, k):
    L1.sort()
    L2.sort()
    s, j = 0, 0
    for i in range(N)[::-1]:
        while j < N and L1[i] + L2[j] < k:
            j += 1
        s += N - j
    return s % 2 * k

t = (xor(A) ^ xor(B)) * (N % 2)
for i in range(28):
    m = (1 << i+1) - 1
    t ^= chk([a&m for a in A], [b&m for b in B], m + 1)

print(t)

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
res = 0
ln = max(max(a), max(b)).bit_length() + 1
for i in range(ln):
  y = (1 << (i + 1))
  u = [x % y for x in a]
  v = [x % y for x in b]
  y >>= 1
  u.sort(reverse = True)
  v.sort()
  t = 0
  k = 0
  kk = 0
  for x in u:
    while k < N and x + v[k] < y: k += 1
    t += N - k
    while kk < N and x + v[kk] < y * 2: kk += 1
    t -= N - kk
  k = 0
  kk = 0
  #print(t)
  for x in u:
    while k < N and x + v[k] < y * 2 + y: k += 1
    t += N - k
    while kk < N and x + v[kk] < y * 4: kk += 1
    t -= N - kk
    #print(t)
  #print(u, v, t)
  res ^= t % 2 * y
print(res)


import bisect

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

ans = 0
for i in range(29):
    div_ = pow(2, i+1)
    A_tmp = sorted([x%div_ for x in A])
    B_tmp = sorted([x%div_ for x in B])
    cnt = 0
    tmp = pow(2, i)
    idx1 = N
    idx2 = N
    idx3 = N
    for a in A_tmp:
        idx2 = bisect.bisect_left(B_tmp, 2*tmp-a, hi=idx2)
        idx1 = bisect.bisect_left(B_tmp, tmp-a, hi=min(idx1, idx2))
        idx3 = bisect.bisect_left(B_tmp, 3*tmp-a, lo=idx2, hi=idx3)
        cnt += ((idx2-idx1)+(N-idx3))%2
    if cnt % 2 == 1:
        ans += tmp
print(ans)


def read():
  return int(input())
 
def reads():
  return [int(x) for x in input().split()]
 
N = read()
A = reads()
B = reads()
 
D = 28
xor = 0
for d in range(D + 1):
  mask = (1 << (d + 1)) - 1 # [1] * (d+1)
  AA = sorted(x & mask for x in A)
  BB = sorted(x & mask for x in B)
  count = 0
  itr = [N] * 4
  for a in AA:
    vs = [
      (1 << d) - a,
      (1 << (d + 1)) - a,
      (1 << d) + (1 << (d + 1)) - a,
      (1 << (d + 2)) - a
    ]
    for i in range(4):
      while 0 < itr[i] and vs[i] <= BB[itr[i]-1]:
        itr[i] -= 1
    count += (itr[1] - itr[0]) + (itr[3] - itr[2])
  if count & 1:
    xor |= 1 << d
 
print(xor)

from numpy import*
a,b=loadtxt(open(0),'i',skiprows=1)
c=0
l=1<<29
while l:u=l;l>>=1;c+=sum(diff(searchsorted(sort(r_[b%u-u,b%u]),([u],[l])-a%u).T))%2*l
print(c)


"""

https://atcoder.jp/contests/arc092/tasks/arc092_b

桁における1の数の偶奇だけで決まる
1+1 -> 0 (1繰り上がり)
1+0 -> 1
0+0 -> 0
なので、1の位においてはそう

2の位では？繰り上がりがある
繰り上がりも含めて、1がいくつあるかわかればいい
その桁への繰り上がりがあるかは、二分探索でわかるはず

200000*28*log

"""

from sys import stdin
import bisect

N = int(stdin.readline())
a = list(map(int,stdin.readline().split()))
b = list(map(int,stdin.readline().split()))

ans = 0

for i in range(29):

    ndig = 2**i
    now = 0

    for j in a:
        if j & ndig > 0:
            if N % 2 == 1:
                now ^= 1
    for j in b:
        if j & ndig > 0:
            if N % 2 == 1:
                now ^= 1
    
    nb = [j % ndig for j in b]
    nb.sort()
    nb.reverse()
    #print (now)
    
    for j in a:
        
        na = j % ndig
        l = -1
        r = N

        while r-l != 1:
            m = (l+r)//2
            if nb[m] + na < ndig:
                r = m
            else:
                l = m

        if r % 2 == 1:
            now ^= 1

    ans += now * ndig

print (ans)
        


def main():
    from bisect import bisect_right as br
    import numpy as np
    n = int(input())
    a = np.array(list(map(int, input().split())))
    b = np.array(list(map(int, input().split())))
    #n = 100000
    #a = np.array([i+1 for i in range(n)])
    #b = np.array([2*i+2 for i in range(n)])
    a = np.sort(a)
    b = np.sort(b[::-1])
    m = n % 2
    xor = 0
    for i in b:
        xor ^= i
    b = pow(2, 28) - b
    ans = 0
    for loop in range(28, -1, -1):
        j = pow(2, loop)
        k = (xor & j) // j
        temp = br(b, j-1)
        b[temp:] -= j
        b = np.sort(b)
        temp = br(a, j-1)
        k += sum((a & j) // j)
        a[temp:] -= j
        x = (k+br(b, 0))*m % 2
        a = np.sort(a)
        x += np.sum(np.searchsorted(b, a+1))
        ans += (x % 2)*j
    print(ans)


main()


# seishin.py
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

M = 32
MOD = [(2 << i) for i in range(M+1)]

from bisect import bisect
def make(B):
    S = [None]*M
    s = {}; get = s.get
    for b in B:
        s[b] = get(b, 0) ^ 1
    S[M-1] = sorted(b for b in s if s[b])

    for i in range(M-2, -1, -1):
        t = S[i+1]; l = len(t)
        m = MOD[i]
        mid = bisect(t, m-1)
        def gen(p, q):
            while p < mid and q < l:
                u = t[p]; v = t[q]
                if u+m == v:
                    p += 1; q += 1
                elif u+m < v:
                    yield t[p]; p += 1
                else:
                    yield t[q]-m; q += 1
            while p < mid:
                yield t[p]; p += 1
            while q < l:
                yield t[q]-m; q += 1
        *S[i], = gen(0, mid)
    return S
S = make(A)
T = make(B)

ans = 0
if 0 in S[0]:
    ans ^= 1 in T[0]
if 1 in S[0]:
    ans ^= 0 in T[0]

for i in range(1, M):
    s = S[i]; ls = len(S)
    t = T[i]; lt = len(t)
    m = MOD[i]; p = MOD[i-1]
    P = p+m; Q = 2*m

    if lt:
        c = 0
        f = lt
        while P <= t[f-1]:
            f -= 1

        u = f; v = lt
        for a in s:
            while u > -lt and P <= a + t[u-1] + (u > 0)*m:
                u -= 1
            while v > -lt and Q <= a + t[v-1] + (v > 0)*m:
                v -= 1
            c += (v - u)
        if c & 1:
            ans ^= 1 << i
print(ans)

import bisect
import functools
import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

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


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        ret = fn(*args, **kwargs)
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        print(ret)
        return ret

    return wrapper


@debug
def calc_bit(k):
    """
    答えの下から k ビット目を返す
    :param int k:
    :return:
    """
    # 答えの k ビット目が偶数なら 0、奇数なら 1

    # これ以上の桁は不要
    mod = 1 << (k + 1)
    amod = [a & (mod - 1) for a in A]
    bmod = [b & (mod - 1) for b in B]
    amod.sort()
    bmod.sort()
    ret = 0

    # bmod + amod のうち k ビット目が 1 となる数
    # => (1 << k) 以上 (2 << k) 未満または (3 << k) 以上 (4 << k) 未満
    # しゃくとる
    b01 = bisect.bisect_left(bmod, (1 << k) - amod[0])
    b10 = bisect.bisect_left(bmod, (2 << k) - amod[0])
    b11 = bisect.bisect_left(bmod, (3 << k) - amod[0])
    for a in range(len(amod)):
        while b01 - 1 >= 0 and bmod[b01 - 1] >= (1 << k) - amod[a]:
            b01 -= 1
        while b10 - 1 >= 0 and bmod[b10 - 1] >= (2 << k) - amod[a]:
            b10 -= 1
        while b11 - 1 >= 0 and bmod[b11 - 1] >= (3 << k) - amod[a]:
            b11 -= 1
        # (1 << k) 以上 (2 << k) 未満
        ret += b10 - b01
        # (3 << k) 以上 (4 << k) 未満
        ret += len(bmod) - b11

    return ret % 2


ans = 0
for i in range(30):
    ans += calc_bit(i) * (2 ** i)
print(ans)


from bisect import bisect_left
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
T = 1 << 30
for k in range(30, -1, -1):
    cnt = 0

    TT = T << 1
    for i in range(N):
        A[i] %= TT
        B[i] %= TT

    A = sorted(A)
    B = sorted(B)

    d0 = bisect_left(B, T - A[0])
    d1 = bisect_left(B, 2 * T - A[0])
    d2 = bisect_left(B, 3 * T - A[0])
    for i in range(N):
        while d0 - 1 >= 0 and B[d0 - 1] >= T - A[i]:
            d0 -= 1
        while d1 - 1 >= 0 and B[d1 - 1] >= 2 * T - A[i]:
            d1 -= 1
        while d2 - 1 >= 0 and B[d2 - 1] >= 3 * T - A[i]:
            d2 -= 1

        cnt += d1 - d0
        cnt += N - d2

    if cnt % 2 == 1:
        ans |= T

    T = T >> 1

print(ans)

import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
 
def sum_count(A,B,x):
  # A,B is sorted. 
  # return count(a+b < x)
  C = np.searchsorted(B, x-A)
  return C.sum()
 
		
def f(t,A,B):
  power = 1<<t
  mask = (power<<1)-1
  AA = A & mask
  BB = B & mask
  AA.sort()
  BB.sort()

  x1,x2,x3 = (sum_count(AA,BB,v) for v in [power, 2*power, 3*power])
  zero_cnt = x1 + (x3-x2)
  return (N-zero_cnt)%2
  
answer = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		answer += 1<<t

print(answer)


# 写経
# https://atcoder.jp/contests/arc092/submissions/5244389

from bisect import bisect_left

INF = float('inf')

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

def calc_bit(k):
    # これ以上の桁は不要
    mod = 1 << (k + 1)
    amod = [a & (mod - 1) for a in A]
    bmod = [b & (mod - 1) for b in B]
    amod.sort()
    bmod.sort()
    ret = 0

    # bmod + amod のうち k ビット目が 1 となる数
    # => (1 << k) 以上 (2 << k) 未満または (3 << k) 以上 (4 << k) 未満
    # しゃくとる
    b01 = bisect_left(bmod, (1 << k) - amod[0])
    b10 = bisect_left(bmod, (2 << k) - amod[0])
    b11 = bisect_left(bmod, (3 << k) - amod[0])
    for a in range(len(amod)):
        while b01 - 1 >= 0 and bmod[b01 - 1] >= (1 << k) - amod[a]:
            b01 -= 1
        while b10 - 1 >= 0 and bmod[b10 - 1] >= (2 << k) - amod[a]:
            b10 -= 1
        while b11 - 1 >= 0 and bmod[b11 - 1] >= (3 << k) - amod[a]:
            b11 -= 1
        # (1 << k) 以上 (2 << k) 未満
        ret += b10 - b01
        # (3 << k) 以上 (4 << k) 未満
        ret += N - b11

    return ret % 2


ans = 0
for i in range(30):
    ans += calc_bit(i) * (1<<i)
print(ans)


import sys
input = sys.stdin.readline

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

# resort list X O(len(X))
def sorting(X, l):
    eX = []
    oX = []
    for x in X:
        if x&(1<<l):
            oX.append(x)
        else:
            eX.append(x)
    return eX + oX

ans = 0
for shift in range(30):
    A = sorting(A, shift)
    B = sorting(B, shift)
    div = (1<<(shift+1))
    count = 0
    l1 = N
    r1 = N
    l2 = N
    r2 = N
    for a in A:
        while a%div + B[l1-1]%div >= div//2 and l1 > 0:
            l1 -= 1
        while a%div + B[r1-1]%div >= div and r1 > 0:
            r1 -= 1
        while a%div + B[l2-1]%div >= div//2*3 and l2 > 0:
            l2 -= 1
        while a%div + B[r2-1]%div >= 2*div and r2 > 0:
            r2 -= 1
        count += (r1-l1) + (r2-l2)
    if count%2 == 1:
        ans += (1<<shift)

print(ans)

# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

n, = map(int,input().split())
*a, = map(int,input().split())
*b, = map(int,input().split())

def bsort(a,d):
    a0 = []
    a1 = []
    for i in a:
        if i>>d&1:
            a1.append(i)
        else:
            a0.append(i)
    return a0+a1
    

ans = 0
for d in range(29):
    res = 0
    a = bsort(a,d)
    b = bsort(b,d)
    r1 = r2 = r3 = 0
    MASK = (1<<(d+1))-1
    #print([i&MASK for i in a],[i&MASK for i in b])
    for bi in b[::-1]:
        bi &= MASK
        while r1 < n and bi+(a[r1]&MASK) < 1<<d:
            r1 += 1
        while r2 < n and bi+(a[r2]&MASK) < 2<<d:
            r2 += 1
        while r3 < n and bi+(a[r3]&MASK) < 3<<d:
            r3 += 1
        #print(d,bi,r1,r2,r3,n)
        res += r2-r1 + n-r3
    ans |= (res%2)<<d
    
print(ans)

# seishin.py
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

M = 32
MOD = [(2 << i) for i in range(M+1)]

from bisect import bisect
def make(B, mode):
    S = [None]*M
    s = {}; get = s.get
    for b in B:
        s[b] = get(b, 0) ^ 1
    S[M-1] = sorted(b for b in s if s[b])

    for i in range(M-2, -1, -1):
        t = S[i+1]; l = len(t)
        m = MOD[i]
        mid = bisect(t, m-1)
        def gen(p, q):
            while p < mid and q < l:
                u = t[p]; v = t[q]
                if u+m == v:
                    p += 1; q += 1
                elif u+m < v:
                    yield t[p]; p += 1
                else:
                    yield t[q]-m; q += 1
            while p < mid:
                yield t[p]; p += 1
            while q < l:
                yield t[q]-m; q += 1
        *S[i], = gen(0, mid)
    if mode:
        for i in range(M):
            m = MOD[i]
            S[i] += list(map(lambda x: x+m, S[i]))
    return S
S = make(A, 0)
T = make(B, 1)

ans = 0
if 0 in S[0]:
    ans ^= 1 in T[0]
if 1 in S[0]:
    ans ^= 0 in T[0]

for i in range(1, M):
    s = S[i]; ls = len(S)
    t = T[i]; lt = len(t)
    m = MOD[i]; p = MOD[i-1]
    P = p+m; Q = 2*m

    if lt:
        c = 0
        f = lt
        while P <= t[f-1]:
            f -= 1

        u = f; v = lt
        for a in s:
            while u > 0 and P <= a + t[u-1]:
                u -= 1
            while v > 0 and Q <= a + t[v-1]:
                v -= 1
            c += (v - u)
        if c & 1:
            ans ^= 1 << i
print(ans)

from numpy import*
a,b=loadtxt(open(c:=0),'i',skiprows=1)
l=1<<29
while l:u=l;l>>=1;c+=sum(diff(searchsorted(sort(r_[b%u-u,b%u]),([u],[l])-a%u).T))%2*l
print(c)

from bisect import bisect_left, bisect_right

def solve():
    maxD = 30

    N = int(input())
    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))

    As.sort()
    Bs.sort()

    ans = 0
    for d in reversed(list(range(maxD))):
        m1 = 1 << d

        iA = bisect_left(As, m1)
        iB = bisect_left(Bs, m1)

        num1 = N * (N-iA + N-iB)

        As = As[:iA] + [A-m1 for A in As[iA:]]
        Bs = Bs[:iB] + [B-m1 for B in Bs[iB:]]

        As.sort()
        Bs.sort(reverse=True)

        iB = 0
        for A in As:
            while iB < N and A + Bs[iB] >= m1:
                iB += 1
            num1 += iB

        Bs.reverse()

        if num1 % 2:
            ans |= m1

    print(ans)


solve()


from bisect import bisect_left,bisect_right
N=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]

num=[0]*30
for i in range(30):
    t = pow(2,i)
    K=sorted(i%(2*t) for i in A)
    L=sorted(i%(2*t) for i in B)
    #L=sort()
    #print(K,L)
    a = 0
    #尺取り法,i*tより小さい整数を数える
    S=[i*t for i in range(1,5)]
    count=[N]*4
    for k in K:
        for j in range(4):
            while L[count[j]-1]+k>=S[j] and count[j]>0:
                count[j]-=1
        a +=count[3]-count[2]+count[1]-count[0]
        #print(count,a)
    num[i]=a%2
ans =0
s=1
for z in num:
    ans += z*s
    s*=2
print(ans)



import numpy as np
n=int(input())
a=np.array(input().split(),dtype=np.int32)
b=np.array(input().split(),dtype=np.int32)
def f(t,a,b):
  power=1<<t
  mask=(power<<1)-1
  aa=a&mask
  bb=b&mask
  aa.sort()
  bb.sort()
  x1,x2,x3=(np.searchsorted(bb,v-aa).sum() for v in [power,power*2,power*3])
  zero_cnt=x1+(x3-x2)
  return (n-zero_cnt)%2
ans=0
for t in range(30):
  x=f(t,a,b)
  if x==1:
    ans+=1<<t
print(ans)


N, = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
mxk = 29
msk = (1<<mxk) - 1
msk2 = (1<<(mxk-1))
r = 0
for i in range(mxk):
    # 下からiビット目をみる
    for j in range(N):
        Q[j] = Q[j] & msk
        P[j] = P[j] & msk
    msk >>= 1
    P.sort()
    Q.sort()
    j1 = N-1
    j2 = N-1
    b = 0
    ss = N
#    print(P, Q)
    for l in range(N):
        if P[l] & msk2:
            ss = l
            break
        k1 = msk2 - (P[l]&msk)
        k2 = k1 + msk2
        while j1 >= 0:
            if Q[j1] < k1:
                break
            j1 -= 1
        while j2 >= 0:
            if Q[j2] < k2:
                break
            j2 -= 1
        b += j2 - j1
#        print("a",j2-j1,k1,k2,j1,j2)

    j1 = N-1
    j2 = N-1
#    print(ss)
    for l in range(ss, N):
        k1 = msk2 - (P[l]&msk)
        k2 = k1 + msk2
        while j1 >= 0:
            if Q[j1] < k1:
                break
            j1 -= 1
        while j2 >= 0:
            if Q[j2] < k2:
                break
            j2 -= 1
#        print("b",j1 - j2 + N)
        b += j1 + N - j2

#    b = 0
#    for p in P:
#        if p & msk2:
#            x = g(2*msk2 - (p&msk))
#            z = g(msk2 - (p&msk))
#            b += z+N-x
#        else:
#            x = g(2*msk2 - (p&msk))
#            z = g(msk2 - (p&msk))
#            b += x-z
#    print(b, r, i)
    if b%2:
        r += 1<<(mxk-1-i)
    msk2 >>= 1
print(r)


import numpy as np
n=int(input())
a=np.array(input().split(),dtype=np.int32)
b=np.array(input().split(),dtype=np.int32)
def f(t,a,b):
  power=1<<t
  mask=(power<<1)-1
  aa=a&mask
  bb=b&mask
  aa.sort()
  bb.sort()
  x1,x2,x3=(np.searchsorted(bb,v-aa).sum() for v in [power,power*2,power*3])
  zero_cnt=x1+(x3-x2)
  return (n-zero_cnt)%2
ans=0
for t in range(30):
  x=f(t,a,b)
  if x==1:
    ans+=1<<t
print(ans)

from bisect import bisect_left

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

m = 30
d = []
# d[i] = 1<<i
for i in range(m+1):
    d.append(1<<i)

c = [[] for i in range(m)]
for bi in b:
    for i in range(m):
        c[i].append(bi&(d[i+1]-1))
for i in range(m):
    c[i].sort()

keta = [0]*m

# しゃくとりするなら桁ごとにやるしか無い
for i in range(m):
    aa = [ai&(d[i+1]-1) for ai in a]
    aa.sort()
    a0 = aa[0]

    i1 = d[i]
    i2 = d[i+1]
    i3 = i2+i1
    b1 = bisect_left(c[i], i1-a0)
    b2 = bisect_left(c[i], i2-a0)
    b3 = bisect_left(c[i], i3-a0)

    for ai in aa:
        # 尺取
        # aiは大きくなる→境界は小さくなる
        # 引いたあとのindexが0以上であることも必要
        while b1-1 >= 0 and c[i][b1-1] >= i1-ai:
            b1 -= 1
        while b2-1 >= 0 and c[i][b2-1] >= i2-ai:
            b2 -= 1
        while b3-1 >= 0 and c[i][b3-1] >= i3-ai:
            b3 -= 1
        keta[i] += b2-b1 + n-b3
    keta[i] %= 2

#print(keta)

ans = 0
for i in range(m):
    ans += keta[i]*(1<<i)

print(ans)

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
 
def sum_count(A,B,x):
    # A,B is sorted. 
    # return count(a+b < x)
    p = len(B)-1
    result = 0
    for a in A:
        while p != -1 and a + B[p] >= x:
            p -= 1
        result += p+1
    return result
 
		
def f(t,A,B):
    power = (1<<t)
    AA = [x&(2*power-1) for x in A]
    BB = [x&(2*power-1) for x in B]
    AA.sort()
    BB.sort()
    
    x1,x2,x3 = (sum_count(AA,BB,v) for v in [power, 2*power, 3*power])
    zero_cnt = x1 + (x3-x2)
    return (N-zero_cnt)%2
  
ans = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		ans += 1<<t
 
print(ans)

N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]

def xor(L):
    a = 0
    for l in L: a ^= l
    return a

def chk(L1, L2, k):
    L1.sort()
    L2.sort()
    s, j = 0, 0
    for i in range(N)[::-1]:
        while j < N and L1[i] + L2[j] < k:
            j += 1
        s += N - j
    return s % 2 * k

t = (xor(A) ^ xor(B)) * (N % 2)
for i in range(28):
    m = 1 << i+1
    t ^= chk([a%m for a in A], [b%m for b in B], m)

print(t)

from numpy import*
a,b=loadtxt(open(0),'i',skiprows=1)
c=0
l=1<<29
while l:u=l;l>>=1;c+=sum(diff(searchsorted(sort(hstack((b%u-u,b%u))),([u],[l])-a%u).T))%2*l
print(c)

"""
感想
- 桁dp,その桁に1立つか調べる
- 桁に1が立つ=値の範囲が[T,2T), [3T, 4T)...
- その桁をしるためにはmod 2*Tの値だけ見れば十分
- 値の範囲の個数をbisectで探る
- bisectだとpythonだと死ぬ
  - NlogNはだめ?
  - 尺取で2*Nにする
  - でもソートしてるからNlogNじゃ？
  - 定数倍のギリギリの問題？=>bisect一個ならセーフ, 探索範囲絞ってbisectのコードは本当にギリギリで運次第でAC(同じコードでTLEとAC)
"""
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(29):
    div_ = pow(2, i+1)
    A_tmp = sorted([x%div_ for x in A])
    B_tmp = sorted([x%div_ for x in B])
    cnt = 0
    tmp = pow(2, i)
    idx1 = N
    idx2 = N
    idx3 = N
    for a in A_tmp:
        while idx2>0 and B_tmp[idx2-1]>=2*tmp-a:
            idx2 -= 1
        while idx1>0 and B_tmp[idx1-1]>=tmp-a:
            idx1 -= 1
        while idx3>0 and B_tmp[idx3-1]>=3*tmp-a:
            idx3 -= 1
        cnt += ((idx2-idx1)+(N-idx3))%2
    if cnt % 2 == 1:
        ans += tmp
print(ans)


import numpy as np
n=int(input())
a=np.array(input().split(),dtype=np.int32)
b=np.array(input().split(),dtype=np.int32)
def f(t,a,b):
  power=1<<t
  mask=(power<<1)-1
  aa=a&mask
  bb=b&mask
  aa.sort()
  bb.sort()
  x1,x2,x3=(np.searchsorted(bb,v-aa).sum() for v in [power,power*2,power*3])
  zero_cnt=x1+(x3-x2)
  return (n*n-zero_cnt)%2
ans=0
for t in range(30):
  x=f(t,a,b)
  if x==1:
    ans+=1<<t
print(ans)


import sys,bisect
input = sys.stdin.readline


def main():
    n = int(input())
    a = tuple(map(int,input().split()))
    b = tuple(map(int,input().split()))


    res = 0
    p = 0

    for i in range(1,30):
        p += 1<<(i-1)
        A = []
        B = []

        for j in range(n):
            A.append(a[j]&p)
            B.append(b[j]&p)
        A.sort()
        B.sort()

        cnt = 0

        q2 = p+1
        q1 = q2>>1
        q3 = q2<<1

        k1,k2,k3,k4 = 0,0,0,0

        for j in range(n-1,-1,-1):
            while k1 < n and A[j]+B[k1] < q1:
                k1 += 1
            while k2 < n and A[j]+B[k2] < q2:
                k2 += 1
            while k3 < n and A[j]+B[k3] < 3*q1:
                k3 += 1
            while k4 < n and A[j]+B[k4] < q3:
                k4 += 1
            cnt += k4 + k2 - k1 - k3

        
        if cnt%2 != 0:
            res += 1<<(i-1)

    print(res)


def __starting_point():
    main()
__starting_point()

# seishin.py
N = int(input())
*A, = map(int, input().split())
*B, = map(int, input().split())

M = 32
MOD = [(2 << i) for i in range(M+1)]

from bisect import bisect
def make(B, mode):
    S = [None]*M
    s = {}; get = s.get
    for b in B:
        s[b] = get(b, 0) ^ 1
    S[M-1] = sorted(b for b in s if s[b])

    for i in range(M-2, -1, -1):
        t = S[i+1]; l = len(t)
        m = MOD[i]
        mid = q = bisect(t, m-1)
        p = 0
        if q < l:
            if p < mid:
                def gen(p, q):
                    u = t[p]; v = t[q]
                    while p < mid and q < l:
                        if u+m == v:
                            p += 1; u = t[p] if p < mid else None
                            q += 1; v = t[q] if q < l else None
                        elif u+m < v:
                            yield u
                            p += 1; u = t[p] if p < mid else None
                        else:
                            yield v-m
                            q += 1; v = t[q] if q < l else None
                    while p < mid:
                        yield t[p]; p += 1
                    while q < l:
                        yield t[q]-m; q += 1
                *S[i], = gen(p, q)
            else:
                *S[i], = (u-m for u in t)
        else:
            *S[i], = t
    if mode:
        for i in range(M):
            m = MOD[i]
            S[i] += list(map(lambda x: x+m, S[i]))
    return S
S = make(A, 0)
T = make(B, 1)

ans = 0
if 0 in S[0]:
    ans ^= 1 in T[0]
if 1 in S[0]:
    ans ^= 0 in T[0]

for i in range(1, M):
    s = S[i]; ls = len(S)
    t = T[i]; lt = len(t)
    m = MOD[i]; p = MOD[i-1]
    P = p+m; Q = 2*m

    if lt:
        c = 0
        f = lt
        while P <= t[f-1]:
            f -= 1

        u = f; v = lt
        for a in s:
            while u > 0 and P <= a + t[u-1]:
                u -= 1
            while v > 0 and Q <= a + t[v-1]:
                v -= 1
            c += (v - u)
        if c & 1:
            ans ^= 1 << i
print(ans)

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

A.sort()
B.sort()

Bit_num = max(A[-1],B[-1]).bit_length()

def derive(i, A, B): #i桁目を求める
  pow_2_i = pow(2,i)
  a = [x % pow_2_i for x in A]
  b = [x % pow_2_i for x in B]
  a.sort()
  b.sort()
  #print(i,a,b)
  ans = 0
  
  th1 = pow_2_i + pow_2_i//2 #第１区間を足す
  ib = N-1
  for ia in range(N):
    a_now = a[ia]
    while ib >= 0 and a_now + b[ib] >= th1:
      ib -= 1
    ans += N-1 - ib
    #print(" ", ia, ib,1)
  th2 = pow_2_i #第２区間を引く
  ib = N-1
  for ia in range(N):
    a_now = a[ia]
    while ib >= 0 and a_now + b[ib] >= th2:
      ib -= 1
    ans -= N-1 - ib
    #print(" ", ia,ib,2)
  th3 = pow_2_i//2 #第３区間を足す
  ib = N-1
  for ia in range(N):
    a_now = a[ia]
    while ib >= 0 and a_now + b[ib] >= th3:
      ib -= 1
    ans -= N-1 - ib
    #print(" ", ia,ib,3)  
  return ans % 2 == 1 #Xorをとる。1ならTrue
    
ans = 0
for i in range(Bit_num+1,0,-1):
  ans += int(derive(i, A, B))
  #print(i,ans)
  ans *= 2
  
print((ans//2))


import numpy as np
N = int(input())
A = np.array(input().split(), dtype=np.int32)
B = np.array(input().split(), dtype=np.int32)
	
def f(t,A,B):
  power = 1<<t
  mask = (power<<1)-1
  AA = A & mask
  BB = B & mask
  AA.sort()
  BB.sort()

  x1,x2,x3 = (np.searchsorted(BB, v-AA).sum() for v in [power, 2*power, 3*power])
  zero_cnt = x1 + (x3-x2)
  return (N-zero_cnt)%2
  
answer = 0
for t in range(30):
	x = f(t,A,B)
	if x == 1:
		answer += 1<<t

print(answer)


def main():
    from bisect import bisect_right as br
    n = int(input())
    a = sorted(list(map(int, input().split())))
    b = sorted(list(map(int, input().split())), reverse=True)
    m = n % 2
    xor = 0
    for i in b:
        xor ^= i
    for i in range(n):
        b[i] = 2**28 - b[i]
    ans = 0
    for loop in range(28, -1, -1):
        j = pow(2, loop)
        k = (xor & j) // j
        temp = br(b, j-1)
        for i in range(temp, n):
            b[i] -= j
        b.sort()
        temp = br(a, j-1)
        for i in a[:temp]:
            k += (i & j) // j
        for i in range(temp, n):
            k += (a[i] & j) // j
            a[i] -= j
        x = (k+br(b, 0))*m % 2
        a.sort()
        l = 0
        for i in a:
            while l < n:
                if i >= b[l]:
                    l += 1
                else:
                    break
            x += l % 2
        ans += (x % 2)*j
    print(ans)


main()


import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = 29
val = 0

def lcount(a,b,x):
    """ソート済a,bに対して, a[i]+b[j]<=xなるi,jの個数
    """
    la = len(a)
    lb = len(b)
    j = -1
    ans = 0
    for i in range(la-1, -1, -1):
        while j+1<lb and a[i]+b[j+1]<=x:
            j += 1
        ans += (j+1)
    return ans
for k in range(l):
    # i桁目を求める
    tmp = pow(2, k+1)
    bb = [item%(tmp) for item in b]
    aa = [item%(tmp) for item in a]
    aa.sort()
    bb.sort()
    ans = n**2 - lcount(aa,bb,tmp//2*3-1) + lcount(aa,bb,tmp-1) - lcount(aa,bb,tmp//2-1)
    if ans%2:
        val += pow(2, k)
print(val)

import sys
readline = sys.stdin.readline

N = int(readline())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
A.sort()
B.sort()
cnta = [0]*29
cntb = [0]*29
for idx in range(N):
    a, b = A[idx], B[idx]
    for i in range(29):
        if (1<<i) & a:
            cnta[i] = 1 - cnta[i]
        if (1<<i) & b:
            cntb[i] = 1 - cntb[i]

carry = [0]*30
bwa = [0]*N
bwb = [0]*N
for i in range(29):
    m = (1<<(i+1))-1
    bwbc = sorted([b&m for b in B])
    bwac = sorted([m+1 if a&m == 0 else m&(-(a&m)) for a in A])
    r = N
    for idx in range(N-1, -1, -1):
        a = bwac[idx]
        while r and bwbc[r-1] >= a:
            r -= 1
        carry[i+1] += N - r
        
ans = 0
for i in range(29):
    if (carry[i] + (cnta[i]+cntb[i])*N) % 2 == 1:
        ans |= 1<<i
print(ans)