#include #include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template constexpr T INF = ::numeric_limits::max() / 32 * 15 + 208; int main() { ll d, q; cin >> d >> q; using P = pair; set

m; ll ans = 0; for (int i = 0; i < q; ++i) { ll a, b; scanf("%lld %lld", &a, &b); b++; auto x = m.upper_bound({a, b}); if(x != m.begin()) x--; while(x != m.end() && x->second < a) x++; while(x != m.end() && b >= x->first){ a = min(a, x->first); b = max(b, x->second); x = m.erase(x); } m.emplace(a, b); ans = max(ans, b-a); printf("%lld\n", ans); } return 0; }