#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair Pr; int N, M; int main() { cin >> N >> M; int mark = N; for (int i = 0; i < M; i++) { int P, Q; cin >> P >> Q; if (P == mark)mark = Q; else if (Q == mark)mark = P; } cout << mark << endl; return 0; }