#include #define REP(i, s, n) for (int i = s; i < (int)(n); i++) #define ALL(a) a.begin(), a.end() #define MOD 1000000007 using namespace std; using ll = long long; int main() { ll D; int Q; cin >> D >> Q; set> S; S.insert({-1, -1}); S.insert({D, D}); ll consecutive = 0; while (Q--) { ll a, b; cin >> a >> b; b++; // [a, b) auto itr = prev(S.lower_bound({a, 0})); if (itr->first <= a && a <= itr->second) a = itr->first; for (auto itr = S.lower_bound({a, 0}); a <= itr->first && itr->first < b; ) { b = max(b, itr->second); itr = S.erase(itr); } S.insert({a, b}); consecutive = max(consecutive, b - a); cout << consecutive << endl; } return 0; }