def f(ary)
  n = ary.size
  res = Array.new(n)
  n.times do |i|
    res[i] = ary[i] ^ ary[i-1]
  end
  res
end
def mp_table(ary)
  n = ary.size
  res = Array.new(n)
  res[0] = 0
  cnt = 0
  1.upto(n - 1) do |i|
    if ary[cnt] == ary[i]
      cnt += 1
    else
      cnt = 0
    end
    res[i] = cnt
  end
  res.unshift(-1)
end

N = gets.to_i
A = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

xa = f(A)
xb = f(B)
xa += xa
mp = mp_table(xb)
cnt = 0
ans = []
i = 0
while i < 2 * N
  if cnt == N
    k = i - N
    ans << [k, A[k] ^ B[0]]
    cnt = mp[cnt]
  end
  
  if xb[cnt] == xa[i]
    cnt += 1
    i += 1
  elsif cnt == 0
    i += 1
  else
    cnt = mp[cnt]
  end
end

puts ans.map{|a| a.join(" ")}.join("\n")