#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; int main() { cin.tie(0); ios::sync_with_stdio(false); ll D; int Q; vector> vec; cin >> D >> Q; ll prev = -1; for (int i = 0; i < Q; i++) { ll A, B; cin >> A >> B; ll minA = A; ll maxB = B; for (auto p : vec) { if (p.first == -1 || p.second == -1) { continue; } if ((p.first - 1 <= B && B <= p.second + 1) || (p.first - 1 <= A && A <= p.second + 1)) { minA = min(minA, min(A, p.first)); maxB = max(maxB, max(B, p.second)); } p.first = -1; p.second = -1; } vec.push_back(pair(minA, maxB)); // ll ans = 0; // for (auto p : vec) { // if (p.first == -1 || p.second == -1) // continue; // ans = max(ans, p.second - p.first); // } // cout << ans + 1 << endl; ll ans = max(prev, (maxB - minA)) + 1; cout << ans << endl; prev = ans; } return 0; }