#include //cin, cout #include //vector #include //sort,min,max #include //string #include //fixed #include //setprecision #include //swap using namespace std; int main() { int N, M, P, Q; cin >> N >> M; vector A(4); A[N] = 1; for (int i = 0; i < M; i++) { cin >> P >> Q; swap(A[P], A[Q]); } int max_index = std::distance(A.begin(), std::max_element(A.begin(), A.end())); cout << max_index << endl; return 0; }