#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<typename Monoid, typename OperatorMonoid=Monoid>
struct LazySegmentTree{
	using F=function<Monoid(Monoid, Monoid)>;
	using G=function<Monoid(Monoid, OperatorMonoid, int, int)>;
	using H=function<OperatorMonoid(OperatorMonoid, OperatorMonoid)>;
	int sz;
	vector<Monoid> data;
	vector<OperatorMonoid> lazy;
	const F f;
	const G g;
	const H h;
	const Monoid e1;
	const OperatorMonoid e0;

	LazySegmentTree(int n, const F f, const G g, const H h, const Monoid &e1, const OperatorMonoid &e0): f(f), g(g), h(h), e1(e1), e0(e0){
		sz=1;
		while(sz<n) sz<<=1;
		data.resize(2*sz-1, e1);
		lazy.resize(2*sz-1, e0);
	}

	void build(vector<Monoid> v){
		for(int i=0; i<v.size(); i++) data[i+sz-1]=v[i];
		for(int i=sz-2; i>=0; i--) data[i]=f(data[2*i+1], data[2*i+2]);
	}

	void eval(int k, int l, int r){
		if(lazy[k]!=e0){
			data[k]=g(data[k], lazy[k], l, r);
			if(k<sz-1){
				lazy[2*k+1]=h(lazy[2*k+1], lazy[k]);
				lazy[2*k+2]=h(lazy[2*k+2], lazy[k]);
			}
		}
		lazy[k]=e0;
	}

	void update(int a, int b, const OperatorMonoid &x, int k, int l, int r){
		eval(k, l, r);
		if(r<=a || b<=l) return;
		if(a<=l && r<=b){
			lazy[k]=h(lazy[k], x);
			eval(k, l, r);
		}else{
			update(a, b, x, 2*k+1, l, (l+r)/2);
			update(a, b, x, 2*k+2, (l+r)/2, r);
			data[k]=f(data[2*k+1], data[2*k+2]);
		}
	}
	void update(int a, int b, const OperatorMonoid &x){
		return update(a, b, x, 0, 0, sz);
	}

	Monoid find(int a, int b, int k, int l, int r){
		eval(k, l, r);
		if(b<=l || r<=a) return e1;
		if(a<=l && r<=b) return data[k];
		else return f(find(a, b, 2*k+1, l, (l+r)/2), find(a, b, 2*k+2, (l+r)/2, r));
	}
	Monoid find(int a, int b){
		return find(a, b, 0, 0, sz);
	}
	Monoid operator[](const int &k){
		return find(k, k+1);
	}
};
int main()
{
    int h, w; cin>>h>>w;
    int a[200020], b[200020];
    for(int i=0; i<h; i++){
        cin>>a[i]>>b[i];
        a[i]--;
    }
    auto f=[&](P a, P b){
        return min(a, b);
    };
    auto g=[&](P a, P x, int l, int r){
        return P(x.first-x.second+l, a.second);
    };
    auto H=[&](P x, P y){
        return y;
    };
    const int INF=1e9+7;
    LazySegmentTree<P, P> seg(w, f, g, H, P(INF, INF), P(-1, -1));
    vector<P> v(w);
    int l=a[0], r=b[0];
    for(int i=0; i<w; i++){
        if(a[0]<=i && i<b[0]) v[i]=P(INF, i);
        else v[i]=P(0, i);
    }
    seg.build(v);
    int ans[200020];
    ans[1]=1;
    if(a[0]==0 && b[0]==w) ans[1]=-1;
    for(int i=1; i<h; i++){
        if(l-1>=0){
            seg.update(l, r, P(seg[l-1].first+1, l));
        }
        seg.update(a[i], b[i], P(INF, a[i]));
        l=a[i], r=b[i];
        P p=seg.find(0, w);
        ans[i+1]=p.first;
        if(ans[i+1]>=INF/2) ans[i+1]=-1;
        else ans[i+1]+=i+1;
    }
    for(int i=1; i<=h; i++) cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 16072