Buggy python submission (verdict: Time Limit Exceeded):
# input
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# process/output
# A[i+k+]^A[i+k+1]=B[i]^B[i+1]となるkを求める
AX = [A[i]^A[i-1] for i in range(N)]
BX = [B[i]^B[i-1] for i in range(N)]

ans = []
for k in range(N):
    AX2 = AX[k:N]
    AX2.extend(AX[0:k])
    if AX2 == BX:
        # kに対応するxを求める
        x = A[k]^B[0]
        print(k, x)


Fixed submission:
# input
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# process/output
# A[i+k+]^A[i+k+1]=B[i]^B[i+1]となるkを求め,kからxを求める
AX = [A[i]^A[i-1] for i in range(N)]
AX += AX
BX = [B[i]^B[i-1] for i in range(N)]

#print(AX)
#print(BX)

# BXの頭と終わりが同じ数字の並びの場合、その数mを求める
m = 0
for i in range(1, N):
    if BX[m] == BX[i]:
        m += 1
    else:
        m = 0
#print(m)

i, j, k = 0, 0, 0
while k < N:
    while True:
        #print("i,j: {},{},{}".format(i,j,k))
        if AX[i] == BX[j]:
            if j == N-1:
                print(k, A[k]^B[0])
                i += 1
                j = m
                break
            i += 1
            j += 1
        elif j != 0:
            j -= 1
        else:
            i += 1
            break
    
    k = i-j

Buggy python submission (verdict: Time Limit Exceeded):
# input
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# process/output
# A[i+k+]^A[i+k+1]=B[i]^B[i+1]となるkを求める
AX = [A[i]^A[i+1] for i in range(N-1)]
BX = [B[i]^B[i+1] for i in range(N-1)]
AX.append(A[N-1]^A[0])
BX.append(B[N-1]^B[0])

ans = []
for k in range(N):
    i = 0
    while i < N:
        j = i+k
        if j >= N:
            j -= N

        if not BX[i] == AX[j]:
            break
        i += 1
    
    if i == N:
        # kに対応するxを求める
        x = A[k]^B[0]
        print(k, x)


Fixed submission:
# input
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# process/output
# A[i+k+]^A[i+k+1]=B[i]^B[i+1]となるkを求め,kからxを求める
AX = [A[i]^A[i-1] for i in range(N)]
AX += AX
BX = [B[i]^B[i-1] for i in range(N)]

#print(AX)
#print(BX)

# BXの頭と終わりが同じ数字の並びの場合、その数mを求める
m = 0
for i in range(1, N):
    if BX[m] == BX[i]:
        m += 1
    else:
        m = 0
#print(m)

i, j, k = 0, 0, 0
while k < N:
    while True:
        #print("i,j: {},{},{}".format(i,j,k))
        if AX[i] == BX[j]:
            if j == N-1:
                print(k, A[k]^B[0])
                i += 1
                j = m
                break
            i += 1
            j += 1
        elif j != 0:
            j -= 1
        else:
            i += 1
            break
    
    k = i-j

Buggy python submission (verdict: Time Limit Exceeded):
# input
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# process
# A[i+k+]^A[i+k+1]=B[i]^B[i+1]となるkを求める
AX = [0]*N
BX = [0]*N
for i in range(N-1):
    AX[i] = A[i]^A[i+1]
    BX[i] = B[i]^B[i+1]
AX[N-1] = (A[N-1]^A[0])
BX[N-1] = (B[N-1]^B[0])

ans = []
for k in range(N):
    i = 0
    while i < N:
        j = i+k
        if j >= N:
            j -= N

        if not BX[i] == AX[j]:
            break
        i += 1
    
    if i == N:
        # kに対応するxを求める
        x = A[k]^B[0]
        ans.append((k, x))

# output
for k, x in ans:
    print("{} {}".format(k,x))


Fixed submission:
# input
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

# process/output
# A[i+k+]^A[i+k+1]=B[i]^B[i+1]となるkを求め,kからxを求める
AX = [A[i]^A[i-1] for i in range(N)]
AX += AX
BX = [B[i]^B[i-1] for i in range(N)]

#print(AX)
#print(BX)

# BXの頭と終わりが同じ数字の並びの場合、その数mを求める
m = 0
for i in range(1, N):
    if BX[m] == BX[i]:
        m += 1
    else:
        m = 0
#print(m)

i, j, k = 0, 0, 0
while k < N:
    while True:
        #print("i,j: {},{},{}".format(i,j,k))
        if AX[i] == BX[j]:
            if j == N-1:
                print(k, A[k]^B[0])
                i += 1
                j = m
                break
            i += 1
            j += 1
        elif j != 0:
            j -= 1
        else:
            i += 1
            break
    
    k = i-j