N = gets.to_i
As, Bs = readlines.map{|l| l.split.map(&:to_i)}

def z(s)
  l = s.length
  res = Array.new(l, 0)
  res[0] = l
  i, j = 1, 0
  while i < l
    j += 1 while i + j < l && s[j] == s[i + j]
    res[i] = j
    if j == 0
      i += 1
      next
    end
    k = 1
    while i + k < l && k + res[k] < j
      res[i + k] = res[k]
      k += 1
    end
    i += k
    j -= k
  end
  res
end

f = ->(a){a.cycle.each_cons(2).take(N).map{|x, y| x^y}}
a = z(f[Bs] + f[As]*2)
(0 ... N).each{|k| puts "#{k} #{As[k]^Bs[0]}" if a[k + N] >= N}