output_description: Print all pairs (k, x) such that a' and b will be equal, using one line for
  each pair, in ascending order of k (ascending order of x for pairs with the
  same k).
  
  If there are no such pairs, the output should be empty.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      a_0 a_1 ... a_{N-1}
      b_0 b_1 ... b_{N-1}
attempt: class RollingHash(object):
      """
      construct: O(N)
      query:
          hash: O(1)
          lcp: O(logN)
          search: O(N)
      """
  
      __base1 = 1007
      __mod1 = 10**9
      __base2 = 1009
      __mod2 = 10**7
  
      def __init__(self, s):
          n = len(s)
          self.__s = s
          self.__n = n
          b1 = self.__base1
          m1 = self.__mod1
          b2 = self.__base2
          m2 = self.__mod2
          H1, H2 = [0] * (n + 1), [0] * (n + 1)
          P1, P2 = [1] * (n + 1), [1] * (n + 1)
          for i in range(n):
              H1[i + 1] = (H1[i] * b1 + (s[i])) % m1
              H2[i + 1] = (H2[i] * b2 + (s[i])) % m2
              P1[i + 1] = P1[i] * b1 % m1
              P2[i + 1] = P2[i] * b2 % m2
          self.__H1 = H1
          self.__H2 = H2
          self.__P1 = P1
          self.__P2 = P2
  
      @property
      def str(self):
          return self.__s
  
      @property
      def len(self):
          return self.__n
  
      def hash(self, l, r=None):
          """
          l,r: int (0<=l<=r<=n)
          return (hash1,hash2) of S[l:r]
          """
          m1 = self.__mod1
          m2 = self.__mod2
          if r is None:
              r = self.__n
          assert 0 <= l <= r <= self.__n
          hash1 = (self.__H1[r] - self.__P1[r - l] * self.__H1[l] % m1) % m1
          hash2 = (self.__H2[r] - self.__P2[r - l] * self.__H2[l] % m2) % m2
          return hash1, hash2
  
      @classmethod
      def lcp(cls, rh1, rh2, l1, l2, r1=None, r2=None):
          """
          rh1,rh2: RollingHash object
          l1,l2,r1,r2: int 0<=l1<=r1<=r1.len, 0<=l2<=r2<=rh2.len
          return lcp length between rh1[l1:r1] and rh2[l2:r2]
          """
          if r1 is None:
              r1 = rh1.__n
          if r2 is None:
              r2 = rh2.__n
          assert 0 <= l1 <= r1 <= rh1.__n and 0 <= l2 <= r2 <= rh2.__n
          L = 0
          R = min(r1 - l1, r2 - l2)
          if rh1.hash(l1, l1 + R) == rh2.hash(l2, l2 + R):
              return R
          while R - L > 1:
              H = (L + R) // 2
              if rh1.hash(l1, l1 + H) == rh2.hash(l2, l2 + H):
                  L = H
          else:
              R = H
          return L
  
      @classmethod
      def search(cls, pattern, text):
          """
          pattern,text: RollingHash object
          return list of index i's satisfying text[i:] starts with pattern
          """
          n = text.__n
          m = pattern.__n
          res = []
          for i in range(n - m + 1):
              if text.hash(i, i + m) == pattern.hash(0, m):
                  res.append(i)
          return res
  
  
  def resolve():
      N = int(input())
      A = list(map(int, input().split()))
      B = list(map(int, input().split()))
  
      dA = [A[i] ^ A[(i + 1) % N] for i in range(N)]
      dB = [B[i] ^ B[(i + 1) % N] for i in range(N)]
  
      dA += dA
      # 今回は数字を扱うのでRollingHash: init() ord削除し対応
      RHa = RollingHash(dA)
      RHb = RollingHash(dB)
      query = RHb.hash(0, N - 1)
      ans = []
      for i in range(N):
          val = RHa.hash(i, i + N - 1)
          if val == query:
              ans.append((i, A[i] ^ B[0]))
      ans.sort()
      for k, x in ans:
          print(k, x)
  
  
  if __name__ == "__main__":
      resolve()
  
problem_description: Statement
  
  Given are two sequences a=\\{a_0,\ldots,a_{N-1}\\} and
  b=\\{b_0,\ldots,b_{N-1}\\} of N non-negative integers each.
  
  Snuke will choose an integer k such that 0 \leq k < N and an integer x not
  less than 0, to make a new sequence of length N,
  a'=\\{a_0',\ldots,a_{N-1}'\\}, as follows:
  
    * a_i'= a_{i+k \mod N}\ XOR \ x
  
  Find all pairs (k,x) such that a' will be equal to b.
  
  What is \mbox{ XOR }?
  
  The XOR of integers A and B, A \mbox{ XOR } B, is defined as follows:
  
    * When A \mbox{ XOR } B is written in base two, the digit in the 2^k's place (k \geq 0) is 1 if either A or B, but not both, has 1 in the 2^k's place, and 0 otherwise.
  
  For example, 3 \mbox{ XOR } 5 = 6. (In base two: 011 \mbox{ XOR } 101 = 110.)
samples: [{"input": "3\n    0 2 1\n    1 2 3", "output": "1 3\n    \n\nIf (k,x)=(1,3),\n\n  * a_0'=(a_1\\ XOR \\ 3)=1\n\n  * a_1'=(a_2\\ XOR \\ 3)=2\n\n  * a_2'=(a_0\\ XOR \\ 3)=3\n\nand we have a' = b.\n\n* * *"}, {"input": "5\n    0 0 0 0 0\n    2 2 2 2 2", "output": "0 2\n    1 2\n    2 2\n    3 2\n    4 2\n    \n\n* * *"}, {"input": "6\n    0 1 3 7 6 4\n    1 5 4 6 2 3", "output": "2 2\n    5 5\n    \n\n* * *"}, {"input": "2\n    1 2\n    0 0", "output": "No pairs may satisfy the condition."}]