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
while i < ARG_N do
  xa[i] = ARG_a[i] ^ ARG_a[i-1]
  xb[i] = ARG_b[i] ^ ARG_b[i-1]
  i+=1
end

xa += xa
results = []
i = 0

first_matches = []
while i < ARG_N do
  if xa[i,ARG_N] == xb
    results.push([i, ARG_a[i]^ARG_b[0]])
  end
  i+=1
  while xa[i] != xb[0] && i < ARG_N do
    i += 1
  end
end
results.each do |re|
  puts "#{re[0]} #{re[1]}"
end