#include using namespace std; #define MAX 100002 int n; int k; int x; int a[MAX]; vector > v; int c[MAX]; int main(){ cin >> n >> k >> x; x--; for (int i = 0; i < n; i++)a[i] = i; for (int i = 0; i < x; i++){ int aa, b; scanf("%d%d", &aa, &b); swap(a[aa - 1], a[b - 1]); } int aa, b; char aaa, bbb; cin >> aaa >> bbb; for (int i = x+1; i < k; i++){ scanf("%d%d", &aa, &b); v.push_back(make_pair(aa-1, b-1)); } for (int i = 0; i < n; i++){ scanf("%d", &c[i]); c[i]--; } for (int i = v.size() - 1; i >= 0; i--){ swap(c[v[i].first], c[v[i].second]); } bool flag = false; for (int i = 0; i < n; i++){ if (c[i] != a[i]){ if (flag){ printf(" "); } printf("%d", i + 1); flag = true; } } puts(""); return 0; }