N = gets.to_i
A = gets.chomp.split(" ").map(&:to_i)
B = gets.chomp.split(" ").map(&:to_i)

ae = A.count{|a| a.even?}
ao = N - ae
be = B.count{|a| a.even?}
if be == ae || be == ao then
  AA = A.concat(A.dup)
  cnt = 0
  (0...N).each{|k|
    x = A[k] ^ B[0]
    flg = true
    (0...N).each{|i|
      (flg = false; break) if (AA[i + k] ^ B[i]) != x
    }
    (cnt += 1; printf("#{k} #{x}\n")) if flg
  }
  printf("\n") if cnt == 0
else
  printf("\n")
end
