def divisors(M):#Mの約数列 O(n^(0.5+e))

    import math

    d=[]

    i=1

    while math.sqrt(M)>=i:

        if M%i==0:

            d.append(i)

            if i**2!=M:

                d.append(M//i)

        i=i+1

    d.sort()

    return d



N=int(eval(input()))

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

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

A=[a[i]^a[i-1] for i in range(0,N)]

B=[b[i]^b[i-1] for i in range(0,N)]

d=divisors(N)

perioda=N

for i in range(0,len(d)):

    test=[A[(j+d[i])%N] for j in range(0,N)]

    if test==A:

        perioda=min(perioda,d[i])



periodb=N

for i in range(0,len(d)):

    test=[B[(j+d[i])%N] for j in range(0,N)]

    if test==B:

        periodb=min(periodb,d[i])



if perioda==periodb:

    A=A[:perioda]

    B=B[:periodb]

    kouho=[]

    for i in range(0,len(B)):

        if A[i]==B[0]:

            kouho.append(i)

    ans=-1

    for i in range(0,len(kouho)):

        test=[A[(j+kouho[i])%perioda] for j in range(0,perioda)]

        if test==B:

            ans=kouho[i]

            break

    if ans!=-1:

        for i in range(0,N//perioda):

            print((ans+perioda*i,a[ans+perioda*i]^b[0]))
#Z[i]:length of the longest list starting from S[i] which is also a prefix of S

#O(|S|)

def Z_algorithm(s):

    N = len(s)

    Z_alg = [0]*N



    Z_alg[0] = N

    i = 1

    j = 0

    while i < N:

        while i+j < N and s[j] == s[i+j]:

            j += 1

        Z_alg[i] = j

        if j == 0:

            i += 1

            continue

        k = 1

        while i+k < N and k + Z_alg[k]<j:

            Z_alg[i+k] = Z_alg[k]

            k += 1

        i += k

        j -= k

    return Z_alg



N=int(eval(input()))

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

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

A=[a[i]^a[i-1] for i in range(0,N)]

B=[b[i]^b[i-1] for i in range(0,N)]



data=B+['?']+A+A

s=Z_algorithm(data)

for i in range(N+1,2*N+1):

    if s[i]>=N:

        print((i-N-1,a[i-N-1]^b[0]))
def divisors(M):  # Mの約数列 O(n^(0.5+e))
    import math

    d = []
    i = 1
    while math.sqrt(M) >= i:
        if M % i == 0:
            d.append(i)
            if i**2 != M:
                d.append(M // i)
        i = i + 1
    d.sort()
    return d


N = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [a[i] ^ a[i - 1] for i in range(0, N)]
B = [b[i] ^ b[i - 1] for i in range(0, N)]
d = divisors(N)
perioda = N
for i in range(0, len(d)):
    test = [A[(j + d[i]) % N] for j in range(0, N)]
    if test == A:
        perioda = min(perioda, d[i])
periodb = N
for i in range(0, len(d)):
    test = [B[(j + d[i]) % N] for j in range(0, N)]
    if test == B:
        periodb = min(periodb, d[i])
if perioda == periodb:
    A = A[:perioda]
    B = B[:periodb]
    kouho = []
    for i in range(0, len(B)):
        if A[i] == B[0]:
            kouho.append(i)
    ans = -1
    for i in range(0, len(kouho)):
        test = [A[(j + kouho[i]) % perioda] for j in range(0, perioda)]
        if test == B:
            ans = kouho[i]
            break
    if ans != -1:
        for i in range(0, N // perioda):
            print((ans + perioda * i, a[ans + perioda * i] ^ b[0]))

# Z[i]:length of the longest list starting from S[i] which is also a prefix of S
# O(|S|)
def Z_algorithm(s):
    N = len(s)
    Z_alg = [0] * N
    Z_alg[0] = N
    i = 1
    j = 0
    while i < N:
        while i + j < N and s[j] == s[i + j]:
            j += 1
        Z_alg[i] = j
        if j == 0:
            i += 1
            continue
        k = 1
        while i + k < N and k + Z_alg[k] < j:
            Z_alg[i + k] = Z_alg[k]
            k += 1
        i += k
        j -= k
    return Z_alg


N = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [a[i] ^ a[i - 1] for i in range(0, N)]
B = [b[i] ^ b[i - 1] for i in range(0, N)]
data = B + ["?"] + A + A
s = Z_algorithm(data)
for i in range(N + 1, 2 * N + 1):
    if s[i] >= N:
        print((i - N - 1, a[i - N - 1] ^ b[0]))

-def divisors(M):  # Mの約数列 O(n^(0.5+e)) -    import math - -    d = [] +# Z[i]:length of the longest list starting from S[i] which is also a prefix of S +# O(|S|) +def Z_algorithm(s): +    N = len(s) +    Z_alg = [0] * N +    Z_alg[0] = N -    while math.sqrt(M) >= i: -        if M % i == 0: -            d.append(i) -            if i**2 != M: -                d.append(M // i) -        i = i + 1 -    d.sort() -    return d +    j = 0 +    while i < N: +        while i + j < N and s[j] == s[i + j]: +            j += 1 +        Z_alg[i] = j +        if j == 0: +            i += 1 +            continue +        k = 1 +        while i + k < N and k + Z_alg[k] < j: +            Z_alg[i + k] = Z_alg[k] +            k += 1 +        i += k +        j -= k +    return Z_alg -d = divisors(N) -perioda = N -for i in range(0, len(d)): -    test = [A[(j + d[i]) % N] for j in range(0, N)] -    if test == A: -        perioda = min(perioda, d[i]) -periodb = N -for i in range(0, len(d)): -    test = [B[(j + d[i]) % N] for j in range(0, N)] -    if test == B: -        periodb = min(periodb, d[i]) -if perioda == periodb: -    A = A[:perioda] -    B = B[:periodb] -    kouho = [] -    for i in range(0, len(B)): -        if A[i] == B[0]: -            kouho.append(i) -    ans = -1 -    for i in range(0, len(kouho)): -        test = [A[(j + kouho[i]) % perioda] for j in range(0, perioda)] -        if test == B: -            ans = kouho[i] -            break -    if ans != -1: -        for i in range(0, N // perioda): -            print((ans + perioda * i, a[ans + perioda * i] ^ b[0])) +data = B + ["?"] + A + A +s = Z_algorithm(data) +for i in range(N + 1, 2 * N + 1): +    if s[i] >= N: +        print((i - N - 1, a[i - N - 1] ^ b[0]))