#include using namespace std; #define dump(x) cout << (x) << '\n' #define Int int64_t #define fi first #define se second #define all(x) (x).begin(), (x).end() Int INF = 1e18; int inf = 1e9; Int mod = 1e9+7; int main() { Int x, n; cin >> x >> n; x--; bool a[3] = {}; a[x] = true; for (Int i = 0; i < n; i++) { Int s, t; cin >> s >> t; s--, t--; swap(a[s], a[t]); } if (a[0]) { dump(1); } else if (a[1]) { dump(2); } else { dump(3); } return 0; }