//想定解法 #include #include #include #include using namespace std; int n, k, x; int a[100001], b[100001]; int c[100001]; int d[100001]; int main() { int i; cin >> n >> k >> x; for( i = 1; i <= k; i++ ){ if( i == x ){ string yuki, coder; cin >> yuki >> coder; } else{ cin >> a[i] >> b[i]; } } for( i = 1; i <= n; i++ ){ cin >> c[i]; } for( i = 1; i <= n; i++ ){ d[i] = i; } for( i = 1; i < x; i++ ){ swap(d[a[i]], d[b[i]]); } for( i = k; i > x; i-- ){ swap(c[a[i]], c[b[i]]); } vector out; for( i = 1; i <= n; i++ ){ if( c[i] != d[i] ){ out.push_back(i); } } cout << out[0] << " " << out[1] << endl; return 0; }