n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

ax = []
bx = []
n.times do |i|
  ax[i] = a[i] ^ a[(i+1)%n]
  bx[i] = b[i] ^ b[(i+1)%n]
end

n.times do |k|
  puts "#{k} #{a[k] ^ b[0]}" if ax.rotate(k) == bx
end