#include using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)<> N >> K >> X; vector A(N); FOR(i, 0, N){ A[i] = i; } FOR(i, 0, X-1){ ll a, b; cin >> a >> b; a--; b--; swap(A[a], A[b]); } char c; cin >> c; cin >> c; vector Y(K-X); vector Z(K-X); FOR(i, 0, K-X){ cin >> Y[i] >> Z[i]; Y[i]--; Z[i]--; } vector C(N); FOR(i, 0, N){ cin >> C[i]; C[i]--; } // swap inversely for(int i=K-X-1; i>=0; i--){ ll y = Y[i]; ll z = Z[i]; swap(C[y], C[z]); } vector ans; FOR(i, 0, N){ if(A[i]!=C[i]) ans.push_back(i); } cout << ans[0]+1 << " " << ans[1]+1 << endl; return 0; }