#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;
//2-dim:vector<vector<Type>> vv(n, vector<Type>(m, d));
//3-dim:vector<vector<vector<Type>>> vvv(n, vector<vector<Type>>(m, vector<Type>(l, d)));

const ll INF = 1e9;
struct LazySegmentTree{
private:
    int n;
    vector<Pll> node; //cnt,idx
    vector<ll> lazy;
    vector<bool> flg;
public:
    Pll merge(Pll x,Pll y){
        return ((x.fi+x.se<y.fi+y.se)?x:y);
    }
    LazySegmentTree(vector<Pll> v){
        int sz=(int)v.size();
        n=1; while(n<sz) n*=2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);
        flg.resize(2*n-1,false);
        for(int i=0;i<2*n-1;i++){
            node[i]={-i,i};
        }
    }
    void eval(int idx,int l,int r){
        if(flg[idx]){
            flg[idx]=false;
            node[idx].fi=lazy[idx];
            node[idx].se=l;
            if(r-l>1){
                /* node[idx]からの伝播 */
                lazy[2*idx+1]=lazy[idx];
                lazy[2*idx+2]=lazy[idx];
                flg[2*idx+1]=true;
                flg[2*idx+2]=true;
            }
            lazy[idx]=0;
        }
    }
    void update(int a,int b,ll x,int idx=0,int l=0,int r=-1){
        if(a>=b) return;
        if(r<0) r=n;
        eval(idx,l,r);
        if(b<=l||r<=a) return;
        if(a<=l&&r<=b){
            lazy[idx]=x;
            flg[idx]=true;
            eval(idx,l,r);
        }else{
            update(a,b,x,2*idx+1,l,(l+r)/2);
            update(a,b,x,2*idx+2,(l+r)/2,r);
            node[idx]=merge(node[2*idx+1],node[2*idx+2]);
        }
    }
    ll query(int a,int b,int idx=0,int l=0,int r=-1){
        if(r<0) r=n;
        if(b<=l||r<=a) return INF;
        eval(idx,l,r);
        if(a<=l && r<=b) return node[idx].fi+node[idx].se;
        ll vl = query(a,b,2*idx+1,l,(l+r)/2);
        ll vr = query(a,b,2*idx+2,(l+r)/2,r);
        return min(vl,vr);
    };
};

signed main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    int h,w; cin >> h >> w;
    vector<Pll> v(w);
    rep(i,w) v[i]={-i,i};
    LazySegmentTree seg(v);
    bool ng=0;
    rep(i,h){
        int qa,qb; cin >> qa >> qb;
        if(ng){
            cout << -1  << endl;
            continue;
        }
        qa--;
        ll upd=INF;
        if(qa!=0){
            upd=seg.query(qa-1,qa);
        }
        seg.update(qa,qb,upd-qa+1);
        ll ans=seg.query(0,w)+i+1;
        if(ans>=INF) ng=1;
        //rep(j,w) cout << seg.query(j,j+1) << " ";
        if(ng){
            cout << -1 << endl;
        }else{
            cout << ans  << endl;
        }
    }
}




Measured memory_bytes: 21832