#include using namespace std; int main() { int N,M; int NowPosition; cin >> N >> M; NowPosition = N; int P[M]; int Q[M]; for(int i = 0; i < M; i++){ cin >> P[i] >> Q[i]; } for(int i =0; i < M; i++){ if(NowPosition == P[i] || NowPosition == Q[i]){ if(NowPosition == P[i]){ NowPosition = Q[i]; } else{ NowPosition = P[i]; } } } cout << NowPosition << endl; return 0; }