ARG_N = gets.to_i
ARG_a = gets.split.map(&:to_i)
ARG_b = gets.split.map(&:to_i)
xa, xb = Array.new(ARG_N), Array.new(ARG_N)
i = 0
OVER = 2**31
while i < ARG_N do
  xa[i] = OVER ^ ARG_a[i] ^ ARG_a[i-1]
  xb[i] = OVER ^ ARG_b[i] ^ ARG_b[i-1]
  i+=1
end
xa += xa
results = []

require 'strscan'
sxa = "|" << xa.join("|") << "|"
sxb = "|" << xb.join("|") << "|"
offset = 0
while(index = sxa.index(sxb, offset))
  i = index / 11
  if i >= ARG_N
    break
  end
  results.push([i, ARG_a[i] ^ ARG_b[0]])
  offset = index+1
end
# i = 0
# 
# while i < ARG_N do
#   if xa[i] == xb[0] && xa[i+1] == xb[1] && xa[i,ARG_N] == xb
#     results.push([i, ARG_a[i]^ARG_b[0]])
#   end
#   i += 1
# end
results.each do |re|
  puts "#{re[0]} #{re[1]}"
end