import sys

input = sys.stdin.readline

N = int(eval(input()))

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

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

ta = [[0] * N for _ in range(30)]

tb = [[0] * N for _ in range(30)]

mxl = max(max(a), max(b)).bit_length()

for i in range(mxl):

  x = 1 << i

  for j in range(N):

    ta[i][j] = int((a[j] & x) > 0)

    tb[i][j] = int((b[j] & x) > 0)



class KmpSearch:

  def __init__(self, word):

    self.word = word

    self.table = [0] * (len(word) + 1)

    self.table[0] = -1

    i, j = 0, 1

    while j < len(self.word):

      matched = self.word[i] == self.word[j]

      if not matched and i > 0:

        i = self.table[i]

      else:

        if matched:

          i += 1

        j += 1

        self.table[j] = i

  def search(self, text):

    table = self.table

    word = self.word

    i, p = 0, 0

    res = []

    while i < len(text):

      if text[i] == word[p]:

        i += 1

        p += 1

      elif p == 0:

        i += 1

      else:

        p = table[p]

      if p == len(word):

        res.append(i - p)

        p = table[p]

    return res

res = [0] * N

vis = [1 for _ in range(N)]

for i in range(mxl):

  kmp = KmpSearch(ta[i])

  s = [0] * (2 * N - 1)

  for j in range(2 * N - 1): s[j] = tb[i][j % N] ^ 1

  xs = set(kmp.search(s))

  tvis = [0] * N

  for j in range(N):

    tvis[j] |= (j in xs)

    res[j] += (j in xs) << i

  xs = set(kmp.search(tb[i] + tb[i][: -1]))

  for j in range(N):

    tvis[j] |= (j in xs)

  for j in range(N):

    vis[j] &= tvis[j]

#print(res, vis)

rres = []

for i in range(N):

  if vis[i]: rres.append(((N - i) % N, res[i]))

rres.sort(key = lambda x: (x[0], x[1]))

for r in rres: print((*r))
import sys

input = sys.stdin.readline

N = int(eval(input()))

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

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



class KmpSearch:

  def __init__(self, word):

    self.word = word

    self.table = [0] * (len(word) + 1)

    self.table[0] = -1

    i, j = 0, 1

    while j < len(self.word):

      matched = self.word[i] == self.word[j]

      if not matched and i > 0:

        i = self.table[i]

      else:

        if matched:

          i += 1

        j += 1

        self.table[j] = i

  def search(self, text):

    table = self.table

    word = self.word

    i, p = 0, 0

    res = []

    while i < len(text):

      if text[i] == word[p]:

        i += 1

        p += 1

      elif p == 0:

        i += 1

      else:

        p = table[p]

      if p == len(word):

        res.append(i - p)

        p = table[p]

    return res



xa = [0] * N

xb = [0] * N

for i in range(N):

  xa[i] = a[i - 1] ^ a[i]

  xb[i] = b[i - 1] ^ b[i]



kmp = KmpSearch(xa)

res = kmp.search(xb + xb[: -1])

rres = []

for x in res: rres.append(((N - x) % N, a[0] ^ b[x]))

rres.sort(key = lambda x: (x[0], x[1]))

for r in rres: print((*r))
import sys

input = sys.stdin.readline
N = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ta = [[0] * N for _ in range(30)]
tb = [[0] * N for _ in range(30)]
mxl = max(max(a), max(b)).bit_length()
for i in range(mxl):
    x = 1 << i
    for j in range(N):
        ta[i][j] = int((a[j] & x) > 0)
        tb[i][j] = int((b[j] & x) > 0)


class KmpSearch:
    def __init__(self, word):
        self.word = word
        self.table = [0] * (len(word) + 1)
        self.table[0] = -1
        i, j = 0, 1
        while j < len(self.word):
            matched = self.word[i] == self.word[j]
            if not matched and i > 0:
                i = self.table[i]
            else:
                if matched:
                    i += 1
                j += 1
                self.table[j] = i

    def search(self, text):
        table = self.table
        word = self.word
        i, p = 0, 0
        res = []
        while i < len(text):
            if text[i] == word[p]:
                i += 1
                p += 1
            elif p == 0:
                i += 1
            else:
                p = table[p]
            if p == len(word):
                res.append(i - p)
                p = table[p]
        return res


res = [0] * N
vis = [1 for _ in range(N)]
for i in range(mxl):
    kmp = KmpSearch(ta[i])
    s = [0] * (2 * N - 1)
    for j in range(2 * N - 1):
        s[j] = tb[i][j % N] ^ 1
    xs = set(kmp.search(s))
    tvis = [0] * N
    for j in range(N):
        tvis[j] |= j in xs
        res[j] += (j in xs) << i
    xs = set(kmp.search(tb[i] + tb[i][:-1]))
    for j in range(N):
        tvis[j] |= j in xs
    for j in range(N):
        vis[j] &= tvis[j]
# print(res, vis)
rres = []
for i in range(N):
    if vis[i]:
        rres.append(((N - i) % N, res[i]))
rres.sort(key=lambda x: (x[0], x[1]))
for r in rres:
    print((*r))

import sys

input = sys.stdin.readline
N = int(eval(input()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))


class KmpSearch:
    def __init__(self, word):
        self.word = word
        self.table = [0] * (len(word) + 1)
        self.table[0] = -1
        i, j = 0, 1
        while j < len(self.word):
            matched = self.word[i] == self.word[j]
            if not matched and i > 0:
                i = self.table[i]
            else:
                if matched:
                    i += 1
                j += 1
                self.table[j] = i

    def search(self, text):
        table = self.table
        word = self.word
        i, p = 0, 0
        res = []
        while i < len(text):
            if text[i] == word[p]:
                i += 1
                p += 1
            elif p == 0:
                i += 1
            else:
                p = table[p]
            if p == len(word):
                res.append(i - p)
                p = table[p]
        return res


xa = [0] * N
xb = [0] * N
for i in range(N):
    xa[i] = a[i - 1] ^ a[i]
    xb[i] = b[i - 1] ^ b[i]
kmp = KmpSearch(xa)
res = kmp.search(xb + xb[:-1])
rres = []
for x in res:
    rres.append(((N - x) % N, a[0] ^ b[x]))
rres.sort(key=lambda x: (x[0], x[1]))
for r in rres:
    print((*r))

-ta = [[0] * N for _ in range(30)] -tb = [[0] * N for _ in range(30)] -mxl = max(max(a), max(b)).bit_length() -for i in range(mxl): -    x = 1 << i -    for j in range(N): -        ta[i][j] = int((a[j] & x) > 0) -        tb[i][j] = int((b[j] & x) > 0) -res = [0] * N -vis = [1 for _ in range(N)] -for i in range(mxl): -    kmp = KmpSearch(ta[i]) -    s = [0] * (2 * N - 1) -    for j in range(2 * N - 1): -        s[j] = tb[i][j % N] ^ 1 -    xs = set(kmp.search(s)) -    tvis = [0] * N -    for j in range(N): -        tvis[j] |= j in xs -        res[j] += (j in xs) << i -    xs = set(kmp.search(tb[i] + tb[i][:-1])) -    for j in range(N): -        tvis[j] |= j in xs -    for j in range(N): -        vis[j] &= tvis[j] -# print(res, vis) +xa = [0] * N +xb = [0] * N +for i in range(N): +    xa[i] = a[i - 1] ^ a[i] +    xb[i] = b[i - 1] ^ b[i] +kmp = KmpSearch(xa) +res = kmp.search(xb + xb[:-1]) -for i in range(N): -    if vis[i]: -        rres.append(((N - i) % N, res[i])) +for x in res: +    rres.append(((N - x) % N, a[0] ^ b[x]))