N, K, Y = map(int, input().split()) A, B = [-1] * (K + 1), [-1] * (K + 1) for i in range(1, K + 1): if i != Y: A[i], B[i] = map(int, input().split()) else: a, b = map(str, input().split()) C = [-1] + list(map(int, input().split())) X = [-1] + [i for i in range(1, N + 1)] for i in range(1, Y): X[A[i]], X[B[i]] = X[B[i]], X[A[i]] for i in range(K, Y, -1): C[A[i]], C[B[i]] = C[B[i]], C[A[i]] ans = [0] * 2 index = 0 for i in range(1, N + 1): if X[i] != C[i]: ans[index] = i index += 1 print(*ans)