#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ull = unsigned long long; using ll = long long; int main() { int n,m; cin >> n >> m; vector cup(3); cup.at(n-1) = 1; for(int i = 0; i < m; ++i) { int p,q; cin >> p >> q; swap(cup.at(p-1),cup.at(q-1)); } int index = 0; for(int i =0; i < 3; ++i) { if(cup.at(i) == 1) { index = i+1; break; } } cout << index << endl; }