#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} #define MAX_N 200005 int main() { int n, k, x; cin >> n >> k >> x; int f[n+1] = {}; rep(i,n+1)f[i] = i; int a[k+1] = {}; int b[k+1] = {}; srep(i,1,k+1){ if(i == x){ char s,t; cin >> s >> t; continue; } cin >> a[i] >> b[i]; if(i < x)swap(f[a[i]], f[b[i]]); } int c[n+1] = {}; srep(i,1,n+1){ cin >> c[i]; } drep(i,k+1){ if(i == x)break; swap(c[a[i]], c[b[i]]); } srep(i,1,n+1){ if(f[i] != c[i])cout << i << ' '; } cout << endl; return 0; }