### BUGGY CODE ###

# F - Xor Shift

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
assert len(a) == N and len(b) == N

# 直前の要素とのxor (循環)
a_xor = [a[i] ^ a[(i + 1) % N] for i in range(N)]
# 直前の要素とのxor (先頭を除く)
b_xor = [b[i] ^ b[i + 1] for i in range(N - 1)]

# (k,x)が解 ⇔ a_xor[k:]がb_xorと一致, x = b[0] XOR a[k]

# a_xorのsuffix-arrayを構築

def make_suffix_array(s):
    """Manber & Myers法で配列sのsuffix-arrayを構築して返す."""
    N = len(s)

    # rank[i] = s[i]
    rank = s[0:N]
    spare = [0] * N  # 作業用配列

    # sa[i] = i
    sa = [i for i in range(N)]
    # s[i]の大小で整列
    sa.sort(key=lambda i: s[i])

    # h = 1, 2, 4, 8, ...
    h = 1
    while h < N:
        sa.sort(key=lambda i: (rank[i], rank[(i + h) % N]))

        # rankの再構築
        cmp = lambda i, j: \
            (rank[(i + h) % N] < rank[(j + h) % N]) if rank[i] == rank[j] \
            else (rank[i] < rank[j])
        spare[sa[0]] = 0
        for j in range(1, N):
            spare[sa[j]] = spare[sa[j - 1]] \
                         + (1 if cmp(sa[j - 1], sa[j]) else 0)
        rank, spare = spare, rank
        h <<= 1
    return sa

sa = make_suffix_array(a_xor)

# a_xor[k:k+N-1] == b_xor となるkを探す

def bin_search(low, high, less_than_target):
    """low: 探索範囲の左端, high: 探索範囲の右端+1,
       less_than_target(i)が偽になる最小のiを返す."""
    while low < high:
        mid = low + (high - low) // 2
        if less_than_target(mid):
            low = mid + 1
        else:
            high = mid
    return low

def axor_less_than_bxor(i):
    """a_xor[sa[i]:sa[i]+N-1] < b_xor か?"""
    for j in range(N - 1):
        if a_xor[(sa[i] + j) % N] != b_xor[j]:
            return a_xor[(sa[i] + j) % N] < b_xor[j]
    return False
def axor_eq_bxor(i):
    """a_xor[sa[i]:sa[i]+N-1] == b_xor か?"""
    return all(a_xor[(sa[i] + j) % N] == b_xor[j] for j in range(N - 1))

i = bin_search(0, N, axor_less_than_bxor)
while i < N and axor_eq_bxor(i):
    k = sa[i]
    print(k, b[0] ^ a[k])
    i += 1


### FIXED CODE ###

# F - Xor Shift

from itertools import chain

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
assert len(a) == N and len(b) == N

# 直前の要素とのxor (循環)
a_xor = [a[i] ^ a[(i + 1) % N] for i in range(N)]
# 直前の要素とのxor (先頭を除く)
b_xor = [b[i] ^ b[i + 1] for i in range(N - 1)]

# (k,x)が解 ⇔ a_xor[k:]がb_xorと一致, x = b[0] XOR a[k]

def kmp_search(T, P):
    m = len(P)
    matches = []
    pi = compute_prefix_func(P)
    q = 0  # number of characters matched
    for i, t in enumerate(T):
        while q > 0 and P[q] != t:
            q = pi[q]  # next character does not match
        if P[q] == t:
            q += 1     # next character matches
        if q == m:
            matches.append(i - (m - 1))
            q = pi[q]  # look for the next match
    return matches

def compute_prefix_func(P):
    m = len(P)
    pi = [0] * (m + 1)
    k = 0
    for q in range(1, m):
        while k > 0 and P[k] != P[q]:
            k = pi[k]
        if P[k] == P[q]:
            k += 1
        pi[q + 1] = k
    return pi

    # pi : {1,2,...,m} -> {0,1,...,m-1}
    # pi[q] = max {k : k < q and P[:q].endswith(P[:k])}

for k in kmp_search(chain(a_xor, a_xor), b_xor):
    if k < N:
        x = b[0] ^ a[k]
        print(k, x)