N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = [-1] * N for i in range(N): A[i] -= 1 B[i] -= 1 C[A[i]] = i mx = -1 ans = [] for i in B: if C[i] > mx: mx = C[i] ans.append(i) ans.sort() for i in ans: print(i + 1)