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

as, bs = [As, Bs].map{|a| a.cycle.each_cons(2).take(2*N).map{|x, y| x^y}}
@ps = [1]; N2.times{|i| @ps[i + 1] = @ps[i]*B % M}
ha, hb = Array.new(N2 + 1, 0), Array.new(N2 + 1, 0)
N2.times do |i|
  ha[i + 1] = (ha[i]*B + as[i]) % M
  hb[i + 1] = (hb[i]*B + bs[i]) % M
end

def get(h, l, r)
  (h[r] - h[l]*@ps[r - l]) % M
end

def lcp(h1, h2, a)
  l, h = 0, N2 + 1 - a
  while h - l > 1
    m = (l + h)/2
    get(h1, a, a + m) == get(h2, 0, m) ? l = m : h = m
  end
  l
end

(0 ... N).each{|k| puts "#{k} #{As[k]^Bs[0]}" if lcp(ha, hb, k) >= N}