import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools N,K,X = map(int,readline().split()) AB1 = list(tuple(map(int,readline().split())) for _ in range(X-1)) readline() AB2 = list(tuple(map(int,readline().split())) for _ in range(K-X)) *C, = map(int,read().split()) before = list(range(N+1)) after = [0] + C for a,b in AB1: before[a], before[b] = before[b], before[a] for a,b in AB2[::-1]: after[a], after[b] = after[b], after[a] diff = [i for i,(x,y) in enumerate(zip(before, after)) if x != y] print(*diff)