Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2
    
    for ai in aa:
        if p1-ai<0:
            j1 = 0
        else:
            j1 = bisect_left(bb,p1-ai)

        j2 = bisect_left(bb,p2-ai)
        
        if p3 - ai > bb[-1]:
            j3 = n
        else:
            j3 = bisect_left(bb,p3-ai)
        
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)    









Fixed submission:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left

def rsort(b,k):
    b0 = []
    b1 = []
    for i in b:
        if i&(1<<k):
            b1.append(i)
        else:
            b0.append(i)
    return b0+b1
    
def f(a,k,bisect_left): #k桁目のxor
    global b
    p1 = 1<<k
    p2 = p1<<1
    p3 = p1+p2

    b = rsort(b,k)
    #print(b)
    
    bb = [i&(p2-1) for i in b]
    
    res = 0
    for ai in a:
        ai &= (p2-1)
        if p1-ai<0:
            j1 = 0
        else:
            j1 = bisect_left(bb,p1-ai)

        j2 = bisect_left(bb,p2-ai)
        
        if p3 - ai > bb[-1]:
            j3 = n
        else:
            j3 = bisect_left(bb,p3-ai)
        
        res += j2-j1+n-j3
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    return (res&1)<<k


ans = 0

for k in range(29):
    ans |= f(a,k,bisect_left)

print(ans)    









Fixed submission:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left as bl
from itertools import accumulate

def f(a,b,k,cnta,accb): #k桁目のxor
    p1 = 1<<k
    p2 = p1<<1
    p3 = p1+p2
    
    res = 0
    if k > N:
        bisect_left=bl
        b = sorted(i&(p2-1) for i in b)
        for ai in a:
            ai &= (p2-1)
            if p1 > b[0]: j1 = bisect_left(b,p1-ai)
            else: j1 = 0
            j2 = bisect_left(b,p2-ai)
            if p3 - ai > b[-1]: j3 = n
            else: j3 = bisect_left(b,p3-ai)
            res += j2-j1+n-j3
        return (res&1)<<k
    else:
        for ai,num in enumerate(cnta):
            if num == 0: continue
            
            #print(cnta,accb,p1,p2,p3,ai+1)
            j1 = j2 = j3 = 0
            if p1-ai-1 >= 0:
                j1 = accb[p1-ai-1]
            if p2-ai-1 >= 0:
                j2 = accb[p2-ai-1]
            if p3-ai-1 >= 0:
                j3 = accb[p3-ai-1]
            res += num&(j2-j1+n-j3)
            
            #print(res,cnta,accb,p1,j1,j2,j3,n)
        return (res&1)<<k
            






N = 17
cnta = 0
accb = [0]

ans = 0
for k in range(28,-1,-1):
    if k == N:
        N2 = 1<<(N+1)
        cnta = [0]*N2
        cntb = [0]*N2
        N2 -= 1
        for i in a: cnta[i&N2] += 1
        for i in b: cntb[i&N2] += 1
        accb = list(accumulate(cntb)) + [n]*(N2+1)
        
    if k < N:
        cnta = [i+j for i,j in zip(cnta[:(1<<(k+1))],cnta[(1<<(k+1)):])]
        cntb = [i+j for i,j in zip(cntb[:(1<<(k+1))],cntb[(1<<(k+1)):])]
        accb = list(accumulate(cntb)) + [n]*(1<<(k+1))
        
    #print(cnta)
    ans |= f(a,b,k,cnta,accb)

print(ans)    









Fixed submission:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left as bl
from itertools import accumulate

def f(a,b,k,cnta,accb): #k桁目のxor
    p1 = 1<<k
    p2 = p1<<1
    p3 = p1+p2
    
    res = 0
    if k > N:
        bisect_left=bl
        b = sorted(i&(p2-1) for i in b)
        for ai in a:
            ai &= (p2-1)
            if p1 > b[0]: j1 = bisect_left(b,p1-ai)
            else: j1 = 0
            j2 = bisect_left(b,p2-ai)
            if p3 - ai > b[-1]: j3 = n
            else: j3 = bisect_left(b,p3-ai)
            res += j2-j1+n-j3
        return (res&1)<<k
    else:
        for ai,num in enumerate(cnta):
            if num == 0: continue
            
            #print(cnta,accb,p1,p2,p3,ai+1)
            j1 = j2 = j3 = 0
            if p1-ai-1 >= 0:
                j1 = accb[p1-ai-1]
            if p2-ai-1 >= 0:
                j2 = accb[p2-ai-1]
            if p3-ai-1 >= 0:
                j3 = accb[p3-ai-1]
            res += num&(j2-j1+n-j3)
            
            #print(res,cnta,accb,p1,j1,j2,j3,n)
        return (res&1)<<k
            






N = 17
cnta = 0
accb = [0]

ans = 0
for k in range(28,-1,-1):
    if k == N:
        N2 = 1<<(N+1)
        cnta = [0]*N2
        cntb = [0]*N2
        N2 -= 1
        for i in a: cnta[i&N2] += 1
        for i in b: cntb[i&N2] += 1
        accb = list(accumulate(cntb)) + [n]*(N2+1)
        
    if k < N:
        cnta = [i+j for i,j in zip(cnta[:(1<<(k+1))],cnta[(1<<(k+1)):])]
        cntb = [i+j for i,j in zip(cntb[:(1<<(k+1))],cntb[(1<<(k+1)):])]
        accb = list(accumulate(cntb)) + [n]*(1<<(k+1))
        
    #print(cnta)
    ans |= f(a,b,k,cnta,accb)

print(ans)    









Fixed submission:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import *
from itertools import accumulate

def f(a,b,k,cnta,accb): #k桁目のxor
    p1 = 1<<k
    p2 = p1<<1
    p3 = p1+p2
    
    res = 0
    if k > N:
        b = sorted(i&(p2-1) for i in b)
        for ai in a:
            ai &= (p2-1)
            if p1 > b[0]: j1 = bisect_left(b,p1-ai)
            else: j1 = 0
            j2 = bisect_left(b,p2-ai)
            if p3 - ai > b[-1]: j3 = n
            else: j3 = bisect_left(b,p3-ai)
            res += j2-j1+n-j3
        return (res&1)<<k
    else:
        for ai,num in enumerate(cnta):
            if num == 0: continue
            
            #print(cnta,accb,p1,p2,p3,ai+1)
            if p1-ai-1 < 0:
                j1 = 0
            else:
                j1 = accb[p1-ai-1]
            if p2-ai-1 < 0:
                j2 = 0
            else:
                j2 = accb[p2-ai-1]
            if p3-ai-1 < 0:
                j3 = 0
            else:
                j3 = accb[p3-ai-1]
            res += num*(j2-j1+n-j3)
            
            #print(res,cnta,accb,p1,j1,j2,j3,n)
        return (res&1)<<k
            






N = 17
cnta = 0
accb = [0]

ans = 0
for k in range(28,-1,-1):
    if k == N:
        N2 = 1<<(N+1)
        cnta = [0]*N2
        cntb = [0]*N2
        N2 -= 1
        for i in a: cnta[i&N2] += 1
        for i in b: cntb[i&N2] += 1
        accb = list(accumulate(cntb)) + [n]*(N2+1)
        
        """
        N2 = 1<<(N+2)
        cntb = [0]*(N2)
        N2 -= 1
        for i in b: cntb[i&N2] += 1
        accb = list(accumulate(cntb))
        """
    if k < N:
        cnta = [i+j for i,j in zip(cnta[:(1<<(k+1))],cnta[(1<<(k+1)):])]
        cntb = [i+j for i,j in zip(cntb[:(1<<(k+1))],cntb[(1<<(k+1)):])]
        accb = list(accumulate(cntb)) + [n]*(1<<(k+1))
        
    #print(cnta)
    ans |= f(a,b,k,cnta,accb)

print(ans)    









Fixed submission:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import *
from itertools import accumulate

def f(a,b,k,cnta,accb): #k桁目のxor
    p1 = 1<<k
    p2 = p1<<1
    p3 = p1+p2
    b = sorted(i&(p2-1) for i in b)
    
    res = 0
    if k > N:
        for ai in a:
            ai &= (p2-1)
            if p1 > b[0]: j1 = bisect_left(b,p1-ai)
            else: j1 = 0
            j2 = bisect_left(b,p2-ai)
            if p3 - ai > b[-1]: j3 = n
            else: j3 = bisect_left(b,p3-ai)
            res += j2-j1+n-j3
        return (res&1)<<k
    else:
        for ai,num in enumerate(cnta):
            if num == 0: continue
            
            #print(cnta,accb,p1,p2,p3,ai+1)
            if p1-ai-1 < 0:
                j1 = 0
            else:
                j1 = accb[p1-ai-1]
            if p2-ai-1 < 0:
                j2 = 0
            else:
                j2 = accb[p2-ai-1]
            if p3-ai-1 < 0:
                j3 = 0
            else:
                j3 = accb[p3-ai-1]
            res += num*(j2-j1+n-j3)
            
            #print(res,cnta,accb,p1,j1,j2,j3,n)
        return (res&1)<<k
            






N = 17
cnta = 0
accb = [0]

ans = 0
for k in range(28,-1,-1):
    if k == N:
        N2 = 1<<(N+1)
        cnta = [0]*N2
        cntb = [0]*N2
        N2 -= 1
        for i in a: cnta[i&N2] += 1
        for i in b: cntb[i&N2] += 1
        accb = list(accumulate(cntb)) + [n]*(N2+1)
        
        """
        N2 = 1<<(N+2)
        cntb = [0]*(N2)
        N2 -= 1
        for i in b: cntb[i&N2] += 1
        accb = list(accumulate(cntb))
        """
    if k < N:
        cnta = [i+j for i,j in zip(cnta[:(1<<(k+1))],cnta[(1<<(k+1)):])]
        cntb = [i+j for i,j in zip(cntb[:(1<<(k+1))],cntb[(1<<(k+1)):])]
        accb = list(accumulate(cntb)) + [n]*(1<<(k+1))
        
    #print(cnta)
    ans |= f(a,b,k,cnta,accb)

print(ans)    









Fixed submission:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import *

def f(a,b,k,cnta): #k桁目のxor
    p1 = 1<<k
    p2 = p1<<1
    p3 = p1+p2
    b = sorted(i&(p2-1) for i in b)
    
    res = 0
    if k > N:
        for ai in a:
            ai &= (p2-1)
            if p1 > b[0]: j1 = bisect_left(b,p1-ai)
            else: j1 = 0
            j2 = bisect_left(b,p2-ai)
            if p3 - ai > b[-1]: j3 = n
            else: j3 = bisect_left(b,p3-ai)
            res += j2-j1+n-j3
        return (res&1)<<k
    else:
        for ai,num in enumerate(cnta):
            if num == 0: continue

            ai &= (p2-1)
            if p1 > b[0]: j1 = bisect_left(b,p1-ai)
            else: j1 = 0
            j2 = bisect_left(b,p2-ai)
            if p3 - ai > b[-1]: j3 = n
            else: j3 = bisect_left(b,p3-ai)
            res += num*(j2-j1+n-j3)
            
            #print(res,cnta,b,p1,j1,j2,j3,n)
        return (res&1)<<k
            






N = 17
N2 = 1<<(N+1)
cnta = 0
#cntb = [0]*N2
#for i in b: cntb[i&N2] += 1

ans = 0
for k in range(28,-1,-1):
    if k == N:
        cnta = [0]*N2
        N2 -= 1
        for i in a: cnta[i&N2] += 1
    if k < N:
        cnta = [i+j for i,j in zip(cnta[:(1<<(k+1))],cnta[(1<<(k+1)):])]
    #print(cnta)
    ans |= f(a,b,k,cnta)

print(ans)    









Fixed submission:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import *

def f(a,b,k): #k桁目のxor
    p1 = 1<<k
    p2 = 2*p1
    p3 = 3*p1
    b = sorted(i&(p2-1) for i in b)

    res = 0
    for ai in a:
        ai &= (p2-1)
        j1 = bisect_left(b,p1-ai)
        j2 = bisect_left(b,p2-ai)
        j3 = bisect_left(b,p3-ai)
        res += j2-j1+n-j3
    return res%2*p1

ans = 0
for k in range(28,-1,-1):
    ans |= f(a,b,k)

print(ans)    




Fixed submission:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import *

def f(a,b,k): #k桁目のxor
    p1 = 1<<k
    p2 = 2*p1
    p3 = 3*p1
    a = [i&(p2-1) for i in a]
    b = [i&(p2-1) for i in b]
    b.sort()
    
    res = 0
    for ai in a:
        j1 = bisect_left(b,p1-ai)
        j2 = bisect_left(b,p2-ai)
        j3 = bisect_left(b,p3-ai)
        res += j2-j1+n-j3
    return res%2

ans = 0
for k in range(28,-1,-1):
    ans |= f(a,b,k)*(1<<k)

print(ans)    




Fixed submission:
# coding: utf-8
# Your code here!

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]
b = [int(i) for i in readline().split()]

from bisect import bisect_left


ans = 0

for k in range(29):
    a0 = []
    a1 = []
    a0a = a0.append
    a1a = a1.append
    
    b0 = []
    b1 = []
    b0a = b0.append
    b1a = b1.append
    for i in a: #基数ソート
        if i&(1<<k): a1a(i)
        else: a0a(i)
    for i in b: #基数ソート
        if i&(1<<k): b1a(i)
        else: b0a(i)
    
    a = a0+a1
    b = b0+b1
    mask = (1<<(k+1))-1
    
    aa = [i&mask for i in a]
    bb = [i&mask for i in b]
    
    res = 0
    p1 = 1<<k
    p2 = mask+1
    p3 = p1+p2

    j1=j2=j3=0    
    for ai in reversed(aa):
        while j1 < n and ai+bb[j1] < p1:
            j1 += 1
        while j2 < n and ai+bb[j2] < p2:
            j2 += 1
        while j3 < n and ai+bb[j3] < p3:
            j3 += 1
        res += j2-j1+n-j3
        #if k < 3: print(ai,p2,res,bb,j1,j2,j3,n)
        #print(bb,p2,ai,j1,j2,j3,n,"R",res)    
    ans |= (res&1)<<k
    



print(ans)