N = gets.to_i
S = gets.chomp.split
T = gets.chomp.split

S.zip(T).each.with_index(1) do |(s, t), i|
  if s != t
    puts [i, s, t]
    exit
  end
end