#include using namespace std; int main() { constexpr int64_t inf = 2e18; int64_t d, q; cin >> d >> q; map mp; mp[-inf] = -inf; mp[inf] = inf; int64_t ans = 0; for (int i = 0; i < q; i++) { int64_t a, b; cin >> a >> b; int64_t l = a, r = b; auto it = mp.upper_bound(a); it--; if (it->second >= a - 1) { l = it->first; mp.erase(it); } it = mp.upper_bound(a); while (it->first <= b + 1) { r = max(r, it->second); it = mp.erase(it); } mp[l] = r; ans = max(ans, r - l + 1); cout << ans << endl; } return 0; }