#include #include #include #include #include #include #include #include using namespace std; using ll = long long; const ll mod = 1000000007; int n, m; string s, t; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m; int pos = n; int num[4] = {0, 1, 2, 3 }; while (m > 0) { int a, b; cin >> a >> b; if (pos == a) { pos = b; } else if (pos == b) { pos = a; } m--; } cout << pos << endl; return 0; }