import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ArrayDeque befores = new ArrayDeque<>(); ArrayDeque afters = new ArrayDeque<>(); for (int i = 0; i < n; i++) { befores.add(sc.nextInt()); } for (int i = 0; i < n; i++) { afters.add(sc.nextInt()); } HashSet loses = new HashSet<>(); TreeSet wins = new TreeSet<>(); while (afters.size() > 0) { int x = afters.poll(); if (loses.contains(x)) { continue; } while (befores.size() > 0) { int y = befores.poll(); if (x == y) { break; } loses.add(y); } wins.add(x); } StringBuilder sb = new StringBuilder(); for (int x : wins) { sb.append(x).append("\n"); } System.out.print(sb); } }