B = (1e6 + 7).to_i
H = (1e9 + 7).to_i

def gen_hash(m, n, s)

  hash = 0
  n.times do |i|
    hash = hash * B + s[i]
    hash %= H
  end

  hash
end

def main
  n = gets.chomp.to_i
  a = gets.chomp.split.map(&:to_i)
  a[n] = a[0]
  b = gets.chomp.split.map(&:to_i)
  b[n] = b[0]
  
  axa = []
  bxa = []
  #a+k xor a+1+k = b xor b+1 となるkを見つける
  bXor = b[0] ^ b[1]
  k = []
  n.times do |i|
    #a[i]xor a[i+1]の配列を作る 
    ax = a[i] ^ a[i+1]
    bx = b[i] ^ b[i+1]
    
    axa[i] = ax
    axa[i+n] = ax
    bxa[i] = bx
 
    if ax == bXor
      k.push(i)
    end
  end

  #全ての要素に対してa+k xor b = Xとなるかを確認する
  #ローリングハッシュで検索する
  b_hash = gen_hash(0, n, bxa)
  a_hash = gen_hash(0, n, axa)

  hash_back = 1
  n.times do
    hash_back *= B
    hash_back %= H
  end

  (n).times do |i|
    if a_hash == b_hash
      x = a[i] ^ b[0]
      puts "#{i} #{x}"
    end

    a_hash = a_hash * B + axa[n+i] - axa[i] * hash_back
    a_hash %= H
  end

end
 
main