import sys

sys.setrecursionlimit(2147483647)

INF = 1 << 60

MOD = 10**9 + 7 # 998244353

input = lambda:sys.stdin.readline().rstrip()



def Z(S):

    n = len(S)

    res = [0] * n

    res[0] = n

    l = r = 0

    for i in range(1, n):

        if res[i - l] < r - i: # 過去の結果が全て使える

            res[i] = res[i - l]

        else:

            l = i

            r = max(i, r) # i < r ならば過去の結果が一部使える

            while r < n and S[r - l] == S[r]: r += 1

            res[i] = r - l

    return res



def resolve():

    n = int(eval(input()))

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

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



    C = [A[i] ^ A[(i + 1) % n] for i in range(n)]

    D = [B[i] ^ B[(i + 1) % n] for i in range(n)]

    prefix = Z(C + D + D)

    res = []

    for k in range(n):

        if prefix[n + k] >= n:

            res.append(((n - k) % n, A[0] ^ B[k]))

    res.sort()

    for pair in res:

        print((*pair))

resolve()
import sys

sys.setrecursionlimit(2147483647)

INF = 1 << 60

MOD = 10**9 + 7 # 998244353

input = lambda:sys.stdin.readline().rstrip()



def Z(S):

    n = len(S)

    res = [0] * n

    res[0] = n

    l = r = 0

    for i in range(1, n):

        if res[i - l] < r - i: # 過去の結果が全て使える

            res[i] = res[i - l]

        else:

            l = i

            r = max(i, r) # i < r ならば過去の結果が一部使える

            while r < n and S[r - l] == S[r]: r += 1

            res[i] = r - l

    return res



def resolve():

    n = int(eval(input()))

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

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



    C = [A[i] ^ A[(i + 1) % n] for i in range(n)]

    D = [B[i] ^ B[(i + 1) % n] for i in range(n)]

    prefix = Z(C + D + D)

    res = []

    for k in range(n, 0, -1):

        if prefix[n + k] >= n:

            print((n - k, A[n - k] ^ B[0]))

resolve()
import sys

sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7  # 998244353
input = lambda: sys.stdin.readline().rstrip()


def Z(S):
    n = len(S)
    res = [0] * n
    res[0] = n
    l = r = 0
    for i in range(1, n):
        if res[i - l] < r - i:  # 過去の結果が全て使える
            res[i] = res[i - l]
        else:
            l = i
            r = max(i, r)  # i < r ならば過去の結果が一部使える
            while r < n and S[r - l] == S[r]:
                r += 1
            res[i] = r - l
    return res


def resolve():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = [A[i] ^ A[(i + 1) % n] for i in range(n)]
    D = [B[i] ^ B[(i + 1) % n] for i in range(n)]
    prefix = Z(C + D + D)
    res = []
    for k in range(n):
        if prefix[n + k] >= n:
            res.append(((n - k) % n, A[0] ^ B[k]))
    res.sort()
    for pair in res:
        print((*pair))


resolve()

import sys

sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7  # 998244353
input = lambda: sys.stdin.readline().rstrip()


def Z(S):
    n = len(S)
    res = [0] * n
    res[0] = n
    l = r = 0
    for i in range(1, n):
        if res[i - l] < r - i:  # 過去の結果が全て使える
            res[i] = res[i - l]
        else:
            l = i
            r = max(i, r)  # i < r ならば過去の結果が一部使える
            while r < n and S[r - l] == S[r]:
                r += 1
            res[i] = r - l
    return res


def resolve():
    n = int(eval(input()))
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = [A[i] ^ A[(i + 1) % n] for i in range(n)]
    D = [B[i] ^ B[(i + 1) % n] for i in range(n)]
    prefix = Z(C + D + D)
    res = []
    for k in range(n, 0, -1):
        if prefix[n + k] >= n:
            print((n - k, A[n - k] ^ B[0]))


resolve()

-    for k in range(n): +    for k in range(n, 0, -1): -            res.append(((n - k) % n, A[0] ^ B[k])) -    res.sort() -    for pair in res: -        print((*pair)) +            print((n - k, A[n - k] ^ B[0]))