#include void run(void){ int n,k,x; scanf("%d%d%d",&n,&k,&x); int A[100001]; int B[100001]; int i; //char s[10]; for(i=1;i<=k;i++){ if(i!=x){ scanf("%d%d",A+i,B+i); } else { while(getchar()!='\n'); while(getchar()!='\n'); } } int D[100001]; for(i=1;i<=n;i++){ D[i]=i; } for(i=1;ix;i--){ int t=C[A[i]]; C[A[i]]=C[B[i]]; C[B[i]]=t; } i=1; while(C[i]==D[i]){ i++; } printf("%d",i); i++; while(C[i]==D[i]){ i++; } printf(" %d\n",i); return; } int main(void){ run(); return 0; }