#include main(){ int N,M; scanf("%d%d",&N,&M); int num = N; for(int i = 0;i < M;i++){ int a,b; scanf("%d%d",&a,&b); if(a == num){ num = b; }else if(b == num){ num = a; } } printf("%d\n",num); }