import java.io.*; class Program{ public static void main(String[] args) { try{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); String[] str1 = br.readLine().split(" "); String[] str2 = br.readLine().split(" "); System.out.println(diffNum(n,str1,str2)+1); System.out.println(str1[diffNum(n,str1,str2)]); System.out.println(str2[diffNum(n,str1,str2)]); }catch(IOException e){ e.getStackTrace(); } } public static int diffNum(int n, String[] s1, String[] s2){ int ans = 0; for(int i=0; i < n; i++){ if(s1[i].equals(s2[i])) ans++; else break; } return ans; } }