n,K,X=map(int,input().split()) c=[] for i in range(K): a,b=input().split() if i!=X-1: c+=[(int(a)-1,int(b)-1)] else: c+=[(-1,-1)] p1=list(range(n)) p2=list(map(int,input().split())) for i in range(n): p2[i]-=1 for i in range(X-1): a,b=c[i] p1[a],p1[b]=p1[b],p1[a] for i in reversed(range(X,K)): a,b=c[i] p2[a],p2[b]=p2[b],p2[a] c=[] for i in range(n): if p1[i]!=p2[i]: c+=[i+1] print(*c)