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

class RollingHash
  def initialize(ary)
    @l = ary.size
    @b1, @b2 = 1007, 2009
    @m1, @m2 = 10**9 + 7, 10**9 + 9
    @h1, @h2 = Array.new(@l + 1, 0), Array.new(@l + 1, 0)
    @p1, @p2 = Array.new(@l + 1, 1), Array.new(@l + 1, 1)
    @l.times do |i|
      @h1[i + 1] = (@h1[i]*@b1 + ary[i]) % @m1
      @h2[i + 1] = (@h2[i]*@b2 + ary[i]) % @m2
      @p1[i + 1] = (@p1[i]* @b1) % @m1
      @p2[i + 1] = (@p2[i]* @b2) % @m2
    end
  end

  def get(l, r)
    r1 = (@h1[r] - @h1[l]*@p1[r - l]) % @m1
    r2 = (@h2[r] - @h2[l]*@p2[r - l]) % @m2
    [r1, r2]
  end

  def lcp(rh, a, b)
    l, h = 0, @l + 1 - [a, b].max
    while h - l > 1
      m = (l + h)/2
      self.get(a, a + m) == rh.get(b, b + m) ? l = m : h = m
    end
    l
  end
end

ha, hb = [As, Bs].map{|ary| RollingHash.new(ary.cycle.each_cons(2).take(2*N).map{|x, y| x^y})}
(0 ... N).each{|k| puts "#{k} #{As[k]^Bs[0]}" if ha.lcp(hb, k, 0) >= N}