#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int inf = 1000000007; constexpr long long mod = 1000000007LL; //constexpr long long mod = 998244353LL; const long double PI = acos((long double)(-1)); using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; void insert(ll l, ll r, set>& st, ll &mx) { auto itr = st.upper_bound({ r + 1, INF }); if (itr == st.begin()) { st.emplace(l, r); chmax(mx, r - l + 1); }else{ itr = prev(itr); while (l - 1 <= itr->second) { chmax(r, itr->second); chmin(l, itr->first); st.erase(itr); if (st.empty()) break; itr = st.upper_bound({ r + 1,INF }); if (itr == st.begin()) break; itr = prev(itr); } st.emplace(l, r); chmax(mx, r - l + 1); } } int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ ll D, Q; scanf("%lld %lld", &D, &Q); ll res = 0; set> st; st.emplace(INF, INF); while (Q--) { ll a, b; scanf("%lld %lld", &a, &b); insert(a, b, st, res); printf("%lld\n", res); } return 0; }