#include <bits/stdc++.h>
using namespace std;

const int inf = numeric_limits<int>::max() / 2;
struct recursive_segment_tree{
	using L = int; // Lazy type
	using Q = int; // Query type
	L apply_lazy(const L &lazy, const L &x, array<int, 2> r, array<int, 2> rr){ // r is a subset of rr
		return !~x ? lazy : x + r[0] - rr[0];
	} // update lazy node representing r with rr
	Q merge(const Q &lval, const Q &rval, int l, int m, int r){
		return min(lval, rval);
	} // merge two nodes representing the intervals [l, m) and [m, r)
	Q apply(const Q &val, const L &x, array<int, 2> r, array<int, 2> rr){ // r is a subset of rr
		return !~x ? val : x + r[0] - rr[0];
	} // apply to node representing r lazy node representing rr
	pair<L, Q> id{-1, inf};
	Q init(int p){
		return id.second;
	}

	int n;
	vector<L> lazy;
	vector<Q> val;
	void push(int u, int l, int r){ // push the internal node u
		if(lazy[u] != id.first && u + 1 < n << 1){
			int m = l + (r - l >> 1), v = u + 1, w = u + (m - l << 1);
			val[v] = apply(val[v], lazy[u], {l, m}, {l, r});
			lazy[v] = apply_lazy(lazy[v], lazy[u], {l, m}, {l, r});
			val[w] = apply(val[w], lazy[u], {m, r}, {l, r});
			lazy[w] = apply_lazy(lazy[w], lazy[u], {m, r}, {l, r});
			lazy[u] = id.first;
		}
	}
	void refresh(int u, int l, int r){
		if(u + 1 < n << 1){
			int m = l + (r - l >> 1), v = u + 1, w = u + (m - l << 1);
			val[u] = merge(val[v], val[w], l, m, r);
		}
		if(lazy[u] != id.first) val[u] = apply(val[u], lazy[u], {l, r}, {l, r});
	}
	template<typename IT>
	recursive_segment_tree(IT begin, IT end): n(end - begin), lazy(n << 1, id.first), val(n << 1, id.second){
		build(begin, end, 0, 0, n);
	}
	recursive_segment_tree(int n): n(n), lazy(n << 1, id.first), val(n << 1, id.second){
		build(0, 0, n);
	}
	template<typename IT>
	void build(IT begin, IT end, int u, int l, int r){
		if(l + 1 == r) val[u] = *begin;
		else{
			int m = l + (r - l >> 1), v = u + 1, w = u + (m - l << 1);
			IT inter = begin + (end - begin >> 1);
			build(begin, inter, v, l, m), build(inter, end, w, m, r);
			val[u] = merge(val[v], val[w], l, m, r);
		}
	}
	void build(int u, int l, int r){
		if(l + 1 == r) val[u] = init(l);
		else{
			int m = l + (r - l >> 1), v = u + 1, w = u + (m - l << 1);
			build(v, l, m), build(w, m, r);
			val[u] = merge(val[v], val[w], l, m, r);
		}
	}
	template<bool First = true>
	void update(int ql, int qr, L x, int u = 0, int l = 0, int r = numeric_limits<int>::max()){
		if(First) r = n;
		if(qr <= l || r <= ql) return;
		if(ql <= l && r <= qr) val[u] = apply(val[u], x, {l, r}, {ql, qr}), lazy[u] = apply_lazy(lazy[u], x, {l, r}, {ql, qr});
		else{
			push(u, l, r);
			int m = l + (r - l >> 1), v = u + 1, w = u + (m - l << 1);
			update<false>(ql, qr, x, v, l, m), update<false>(ql, qr, x, w, m, r);
			refresh(u, l, r);
		}
	} // Apply x to values at [ql, qr)
	template<bool First = true>
	Q query(int ql, int qr, int u = 0, int l = 0, int r = numeric_limits<int>::max()){
		if(First) r = n;
		if(qr <= l || r <= ql) return id.second;
		if(ql <= l && r <= qr) return val[u];
		push(u, l, r);
		int m = l + (r - l >> 1), v = u + 1, w = u + (m - l << 1);
		return merge(query<false>(ql, qr, v, l, m), query<false>(ql, qr, w, m, r), max(ql, l), clamp(m, ql, qr), min(qr, r));
	} // Get the query result for [ql, qr)
};

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	int h, w;
	cin >> h >> w;
	vector<int> a(w);
	recursive_segment_tree tr(a.begin(), a.end());
	for(auto i = 1; i <= h; ++ i){
		int l, r;
		cin >> l >> r, -- l;
		if(!l){
			tr.update(l, r, inf);
		}
		else{
			tr.update(l, r, tr.query(l - 1, l) + 1);
		}
		int res = tr.query(0, w) + i;
		res < inf ? cout << res << "\n" : cout << "-1\n";
	}
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

Measured memory_bytes: 7160