def z_algo(S):

    # Z-algoirhm  O(n)

    # Z[i] := S と S[i:] で prefix が何文字一致しているか

    # 検証: https://atcoder.jp/contests/arc055/submissions/14179788

    i, j, n = 1, 0, len(S)

    Z = [0] * n

    Z[0] = n

    while i < n:

        while i+j < n and S[j] == S[i+j]:

            j += 1

        if j == 0:

            i += 1

            continue

        Z[i] = j

        d = 1

        while i+d < n and d+Z[d] < j:

            Z[i+d] = Z[d]

            d += 1

        i += d

        j -= d

    return Z





N = int(eval(input()))

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

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

A_diff = []

a2 = A[-1]

for a in A:

    A_diff.append(a^a2)

    a2 = a

B_diff = []

b2 = B[-1]

for b in B:

    B_diff.append(b^b2)

    b2 = b

A_diff_2 = A_diff + A_diff[:-1]

Z = z_algo(A_diff_2)

A_diff_str = "_".join(map(str, A_diff_2))

B_diff_str = "_".join(map(str, B_diff))

idx = A_diff_str.find(B_diff_str)

if idx==-1:

    exit()

idx = A_diff_str[:idx].count("_")

Ans = []

b0 = B[-idx]

for i, (z, a, b) in enumerate(zip(Z, A, B)):

    if z >= N:

        Ans.append([(idx+i)%N, a^b0])

        # x = [idx, i, a, b, B[-idx]]

        # print(x)

Ans.sort()  # これいる？

for k, x in Ans:

    print(f"{k} {x}")

import os

import sys

import numpy as np



def z_algo(S):

    # Z-algoirhm  O(n)

    # Z[i] := S と S[i:] で prefix が何文字一致しているか

    # 検証: https://atcoder.jp/contests/arc055/submissions/14179788

    i, j, n = 1, 0, len(S)

    Z = np.zeros_like(S)

    Z[0] = n

    while i < n:

        while i+j < n and S[j] == S[i+j]:

            j += 1

        if j == 0:

            i += 1

            continue

        Z[i] = j

        d = 1

        while i+d < n and d+Z[d] < j:

            Z[i+d] = Z[d]

            d += 1

        i += d

        j -= d

    return Z



def solve(N, A, B):

    Diff = np.empty(3*N, dtype=np.int64)

    Diff[0] = B[0] ^ B[-1]

    Diff[1:N] = B[1:] ^ B[:-1]

    Diff[N] = Diff[2*N] = A[0] ^ A[-1]

    Diff[N+1:2*N] = Diff[2*N+1:3*N] = A[1:] ^ A[:-1]

    Z = z_algo(Diff)[N:2*N]

    Ans = [(0,0)]*0

    for i in range(N):

        z = Z[i]

        if z >= N:

            Ans.append((i, B[0]^A[i]))

    if len(Ans):

        return np.array(Ans)

    return np.zeros((0, 2), dtype=np.int64)





# >>> numba compile >>>

numba_config = [

    [z_algo, "i8[:](i8[:])"],

    [solve, "i8[:,:](i8,i8[:],i8[:])"],

]

if sys.argv[-1] == "ONLINE_JUDGE":

    from numba import njit

    from numba.pycc import CC

    cc = CC("my_module")

    for func, signature in numba_config:

        vars()[func.__name__] = njit(signature)(func)

        cc.export(func.__name__, signature)(func)

    cc.compile()

    exit()

elif os.name == "posix":

    exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")

else:

    from numba import njit

    for func, signature in numba_config:

        vars()[func.__name__] = njit(signature, cache=True)(func)

    print("compiled!", file=sys.stderr)

# <<< numba compile <<<





def main():

    N = int(input())

    A = np.array(input().split(), dtype=np.int64)

    B = np.array(input().split(), dtype=np.int64)

    Ans = solve(N, A, B).tolist()

    for k, x in Ans:

        print(f"{k} {x}")



main()

def z_algo(S):
    # Z-algoirhm  O(n)
    # Z[i] := S と S[i:] で prefix が何文字一致しているか
    # 検証: https://atcoder.jp/contests/arc055/submissions/14179788
    i, j, n = 1, 0, len(S)
    Z = [0] * n
    Z[0] = n
    while i < n:
        while i + j < n and S[j] == S[i + j]:
            j += 1
        if j == 0:
            i += 1
            continue
        Z[i] = j
        d = 1
        while i + d < n and d + Z[d] < j:
            Z[i + d] = Z[d]
            d += 1
        i += d
        j -= d
    return Z


N = int(eval(input()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_diff = []
a2 = A[-1]
for a in A:
    A_diff.append(a ^ a2)
    a2 = a
B_diff = []
b2 = B[-1]
for b in B:
    B_diff.append(b ^ b2)
    b2 = b
A_diff_2 = A_diff + A_diff[:-1]
Z = z_algo(A_diff_2)
A_diff_str = "_".join(map(str, A_diff_2))
B_diff_str = "_".join(map(str, B_diff))
idx = A_diff_str.find(B_diff_str)
if idx == -1:
    exit()
idx = A_diff_str[:idx].count("_")
Ans = []
b0 = B[-idx]
for i, (z, a, b) in enumerate(zip(Z, A, B)):
    if z >= N:
        Ans.append([(idx + i) % N, a ^ b0])
        # x = [idx, i, a, b, B[-idx]]
        # print(x)
Ans.sort()  # これいる？
for k, x in Ans:
    print(f"{k} {x}")

import os
import sys
import numpy as np


def z_algo(S):
    # Z-algoirhm  O(n)
    # Z[i] := S と S[i:] で prefix が何文字一致しているか
    # 検証: https://atcoder.jp/contests/arc055/submissions/14179788
    i, j, n = 1, 0, len(S)
    Z = np.zeros_like(S)
    Z[0] = n
    while i < n:
        while i + j < n and S[j] == S[i + j]:
            j += 1
        if j == 0:
            i += 1
            continue
        Z[i] = j
        d = 1
        while i + d < n and d + Z[d] < j:
            Z[i + d] = Z[d]
            d += 1
        i += d
        j -= d
    return Z


def solve(N, A, B):
    Diff = np.empty(3 * N, dtype=np.int64)
    Diff[0] = B[0] ^ B[-1]
    Diff[1:N] = B[1:] ^ B[:-1]
    Diff[N] = Diff[2 * N] = A[0] ^ A[-1]
    Diff[N + 1 : 2 * N] = Diff[2 * N + 1 : 3 * N] = A[1:] ^ A[:-1]
    Z = z_algo(Diff)[N : 2 * N]
    Ans = [(0, 0)] * 0
    for i in range(N):
        z = Z[i]
        if z >= N:
            Ans.append((i, B[0] ^ A[i]))
    if len(Ans):
        return np.array(Ans)
    return np.zeros((0, 2), dtype=np.int64)


# >>> numba compile >>>
numba_config = [
    [z_algo, "i8[:](i8[:])"],
    [solve, "i8[:,:](i8,i8[:],i8[:])"],
]
if sys.argv[-1] == "ONLINE_JUDGE":
    from numba import njit
    from numba.pycc import CC

    cc = CC("my_module")
    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature)(func)
        cc.export(func.__name__, signature)(func)
    cc.compile()
    exit()
elif os.name == "posix":
    exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}")
else:
    from numba import njit

    for func, signature in numba_config:
        vars()[func.__name__] = njit(signature, cache=True)(func)
    print("compiled!", file=sys.stderr)
# <<< numba compile <<<
def main():
    N = int(input())
    A = np.array(input().split(), dtype=np.int64)
    B = np.array(input().split(), dtype=np.int64)
    Ans = solve(N, A, B).tolist()
    for k, x in Ans:
        print(f"{k} {x}")


main()

+import os +import sys +import numpy as np + + -    Z = [0] * n +    Z = np.zeros_like(S) -N = int(eval(input())) -A = list(map(int, input().split())) -B = list(map(int, input().split())) -A_diff = [] -a2 = A[-1] -for a in A: -    A_diff.append(a ^ a2) -    a2 = a -B_diff = [] -b2 = B[-1] -for b in B: -    B_diff.append(b ^ b2) -    b2 = b -A_diff_2 = A_diff + A_diff[:-1] -Z = z_algo(A_diff_2) -A_diff_str = "_".join(map(str, A_diff_2)) -B_diff_str = "_".join(map(str, B_diff)) -idx = A_diff_str.find(B_diff_str) -if idx == -1: +def solve(N, A, B): +    Diff = np.empty(3 * N, dtype=np.int64) +    Diff[0] = B[0] ^ B[-1] +    Diff[1:N] = B[1:] ^ B[:-1] +    Diff[N] = Diff[2 * N] = A[0] ^ A[-1] +    Diff[N + 1 : 2 * N] = Diff[2 * N + 1 : 3 * N] = A[1:] ^ A[:-1] +    Z = z_algo(Diff)[N : 2 * N] +    Ans = [(0, 0)] * 0 +    for i in range(N): +        z = Z[i] +        if z >= N: +            Ans.append((i, B[0] ^ A[i])) +    if len(Ans): +        return np.array(Ans) +    return np.zeros((0, 2), dtype=np.int64) + + +# >>> numba compile >>> +numba_config = [ +    [z_algo, "i8[:](i8[:])"], +    [solve, "i8[:,:](i8,i8[:],i8[:])"], +] +if sys.argv[-1] == "ONLINE_JUDGE": +    from numba import njit +    from numba.pycc import CC + +    cc = CC("my_module") +    for func, signature in numba_config: +        vars()[func.__name__] = njit(signature)(func) +        cc.export(func.__name__, signature)(func) +    cc.compile() -idx = A_diff_str[:idx].count("_") -Ans = [] -b0 = B[-idx] -for i, (z, a, b) in enumerate(zip(Z, A, B)): -    if z >= N: -        Ans.append([(idx + i) % N, a ^ b0]) -        # x = [idx, i, a, b, B[-idx]] -        # print(x) -Ans.sort()  # これいる？ -for k, x in Ans: -    print(f"{k} {x}") +elif os.name == "posix": +    exec(f"from my_module import {','.join(func.__name__ for func, _ in numba_config)}") +else: +    from numba import njit + +    for func, signature in numba_config: +        vars()[func.__name__] = njit(signature, cache=True)(func) +    print("compiled!", file=sys.stderr) +# <<< numba compile <<< +def main(): +    N = int(input()) +    A = np.array(input().split(), dtype=np.int64) +    B = np.array(input().split(), dtype=np.int64) +    Ans = solve(N, A, B).tolist() +    for k, x in Ans: +        print(f"{k} {x}") + + +main()