n = int(input()) A = list(map(int, input().split())) C = [0] * n for i, a in enumerate(A, 1): C[a - 1] = i A = C B = list(map(int, input().split())) C = [0] * n for i, a in enumerate(B, 1): C[a - 1] = i B = C ab = [(a, b, i) for i, (a, b) in enumerate(zip(A, B), 1)] ab.sort(key = lambda x:x[1]) ans = [] max_ = 0 for a, b, i in ab: if a > max_: ans.append(i) max_ = a ans.sort() print(*ans, sep="\n")