def changeCups(cups, changes): for (i, j) in changes: tmp = cups[i - 1] cups[i - 1] = cups[j - 1] cups[j - 1] = tmp def diffCups(A, B): s = [] for i in range(len(A)): if A[i] != B[i]: s += [i + 1] return s N, K, X = tuple(int(i) for i in input().split()) AB1 = [tuple(int(i) for i in input().split()) for i in range(X - 1)] _ = input() AB2 = [tuple(int(i) for i in input().split()) for i in range(K - X)] AB2.reverse() C = [int(i) for i in input().split()] S = [i + 1 for i in range(N)] changeCups(S, AB1) changeCups(C, AB2) print(" ".join([str(i) for i in diffCups(S, C)]))