#include #include #include using namespace std; int main() { int n, m, p[200], q[200]; cin >> n >> m; int ans = n; for(int i=0; i> p[i] >> q[i]; if(p[i] == ans) ans = q[i]; else if(q[i] == ans) ans = p[i]; } cout << ans << endl; return 0; }