[n,k,x] = map(int,input().split(' ')) x -= 1 s = [i for i in range(1,n+1)] tmp = s[:] for i in range(k): if i == x: input() continue [a,b] = map(int,input().split(' ')) a -= 1 b -= 1 s[a],s[b] = s[b],s[a] if i == x-1: tmp = s[:] c = list(map(int,input().split(' '))) t = [s[i] for i in range(n) if s[i] != c[i]] for i in range(n): if tmp[i] in t: print(i+1,end=' ') print("")