#include using namespace std; int main(){ cin.tie(nullptr)->sync_with_stdio(false); int pos, M; cin >> pos >> M; for(int i = 0; i < M; ++i){ int a, b; cin >> a >> b; if(a == pos){ pos = b; } else if(b == pos){ pos = a; } } cout << pos << endl; return 0; }