N = int(input()) A = input() A = A.split(" ") A = [int(i) for i in A] B = input() B = B.split(" ") B = [int(i) for i in B] maxnum = [-1]*N for i in range(N): for j in range(i+1): if(maxnum[i] <= A.index(B[j])): maxnum[i] = A.index(B[j]) if(maxnum[i] == A.index(B[i])): print(B[i])