N = gets.to_i
As, Bs = readlines.map{|l| l.split.map(&:to_i)}
B, M = 1007, 10**9 + 7

def mpow(x, n)
  ret = 1
  while n > 0
    if n.even?
      x = x * x % M
      n >>= 1
    else
      ret = ret * x % M
      n -= 1
    end
  end
  ret
end

P, N2 = mpow(B, N), 2*N
as, bs = [As, Bs].map{|a| a.cycle.each_cons(2).take(2*N).map{|x, y| x^y}}
ha, hb = [as, bs].map{|a| a.each_with_object([0]){|v, o| o << (o.last*B + v) % M}}
f = ->(h, i){(h[i + N] - h[i]*P) % M}
(0 ... N).each{|k| puts "#{k} #{As[k]^Bs[0]}" if f[ha, k] == f[hb, 0]}