#include using namespace std; class RangeSet{ private: const long long INF = 1e18 + 1e8; long long max_range; set> data; // stores the ranges [L, R) public: RangeSet(): max_range(0), data(){ data.emplace(-INF, -INF); data.emplace(INF, INF); } void insert(long long L, long long R){ // Insert a range [L, R) to the set. // if (L >= R) return; auto it = data.lower_bound(make_pair(L, R)); if (L == it->first) return; // [L, R) is covered by *it. L1 == L < R <= R1 if (L <= (--it)->second){ L = it->first; }else{ ++it; } while (it->first <= R){ if (R < it->second) R = it->second; it = data.erase(it); } data.insert(it, make_pair(L, R)); if (max_range < R - L) max_range = R - L; } long long get_max_range(){ return this->max_range; } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); long long D; int Q; cin >> D >> Q; vector> ABs(Q); for (auto & ab: ABs) cin >> ab.first >> ab.second; RangeSet rset; for (auto & ab: ABs){ rset.insert(ab.first, ab.second + 1LL); cout << rset.get_max_range() << '\n'; } return 0; }