#!/usr/bin/env pypy3 import collections def main(): n, k, x = map(int, input().split()) cups = list(range(n)) after = collections.deque() for i in range(k): if i != x - 1: a, b = map(lambda c: int(c) - 1, input().split()) if i < x - 1: cups[a], cups[b] = cups[b], cups[a] else: after.append((a, b)) else: _ = input() final_cups = list(map(lambda c: int(c) - 1, input().split())) while after: a, b = after.pop() final_cups[a], final_cups[b] = final_cups[b], final_cups[a] ans = [] for j in range(n): if cups[j] != final_cups[j]: ans.append(j + 1) print(*ans) if __name__ == '__main__': main()