import sys readline = sys.stdin.readline N, K, X = map(int, readline().split()) A, B = [], [] D = list(range(1, N + 1)) for i in range(K): a, b = readline().split() if a == "?": continue A.append(int(a)-1) B.append(int(b)-1) C = list(map(int, readline().split())) for i in range(X - 1): a, b = A[i], B[i] D[a], D[b] = D[b], D[a] for i in range(K - X): a, b = A[K - 2 - i], B[K - 2 - i] C[a], C[b] = C[b], C[a] ans = [] for i in range(N): if D[i] != C[i]: ans.append(i + 1) ans.sort() print(*ans)