#include #include #include #include using namespace std; typedef long long int ll; int main(){ int n; cin >> n; int m; cin >> m; int ans=n; for(int i=0;i> x >> y; if(x==ans)ans=y; else if(y==ans)ans=x; } cout << ans << endl; }