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となるかを確認する
  sliced = axa[0...n]
  kkk = k.shift
 
  (0..n).to_a.each do |i|
    if i == kkk
      if sliced == bxa
        x = a[kkk] ^ b[0]
        puts "#{kkk} #{x}"
      end
 
      kkk = k.shift
    end
 
    sliced.shift
    sliced.push(axa[n+i])
 
  end
 
end
 
main