#include using namespace std; #define PRINT(n) cout << n << "\n"; #define PRINT2(n, m) cout << n << " " << m << " "<< "\n"; #define REP(i,n) for(int i=0;i<(int)n;++i) void no26(); int main() {cin.tie(0); ios::sync_with_stdio(false); no26();} /********************************/ /** yukicoder No.26 **/ /** by MoonlightSonata **/ /********************************/ void no26(){ int n, m; cin >> n >> m; vector p(m, 0); vector q(m, 0); int ans = n; REP(i,m){ cin >> p[i] >> q[i]; if (ans == p[i]){ ans = q[i]; }else if (ans == q[i]) { ans = p[i]; } } PRINT(ans) }