#define F(i,n) for(int i = 0;i < n;i++) #include int main (void){ int m,n;int p[400]; scanf("%d%d",&m,&n); F(i,n){scanf("%d%d",&p[i],&p[i+1]);i++;} F(i,n){if(p[i]==m)m=p[i+1];else if(p[i+1]==m)m=p[i];i++;} printf("%d\n",m); return(0); }