#include #include using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n, m, p, q; cin >> n >> m; vector pos(3, 0); pos[n - 1] = 1; for (int i = 0; i < m; ++i) { cin >> p >> q; swap(pos[p - 1], pos[q - 1]); } for (int i = 0; i < 3; ++i) { if (pos[i] == 1) cout << i + 1; } return 0; }