#include using namespace std; int main() { vector V(3); int N; cin >> N; N--; V.at(N)++; int M; cin >> M; while (M--) { int a, b; cin >> a >> b; a--, b--; swap(V.at(a), V.at(b)); } for (int i = 0; i < 3; i++) { if (V.at(i)) return cout << i + 1 << "\n", 0; } }