#include <bits/stdc++.h>
#pragma GCC optimize(3, "Ofast")
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
inline int read() {
    int s = 0, w = 1;
    char ch = getchar();
    while (ch < '0' || ch>'9') { if (ch == '-')w = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
    return s * w;
}
#define f(i, l, r) for (int i = l; i <= r; ++i)
#define rf(i, r, l) for (int i = r; i >= l; --i)
#define all(x) (x).begin(), (x).end()
#define l l
#define r r
#define lch (o << 1)
#define rch (o << 1 | 1)
#define mid ((l + r) >> 1)
#define mem(x, y) memset(x, y, sizeof(x))
#define mod1(x) ((x >= mod) && (x -= mod))
#define mod2(x) ((x < 0) && (x += mod))

const int inf = 2e9 + 7;
//const ll INF = INT64_MAX;
double eps = 1e-6;
const int mod = 1e9+7;
const int N = 1e6 + 10;
const double pi = acos(-1.0);
ll power(ll a, ll b) { ll res = 1; while (b) { if (b & 1)res = res * a % mod; a = a * a % mod; b >>= 1; }return res; }
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
void add(ll& a, ll b) { a += b; mod1(a); mod2(a); }
/*int len, C[N], clen;
int id(int v) { return lower_bound(C + 1, C + len, v) - C; }
void initC() { sort(C + 1, C + clen); len = unique(C + 1, C + 1 + clen) - C - 1; }*/

int h, w;

int a[N];
struct node
{
	ll tag, mi,val,mi2;
};
struct ST
{
	node t[N * 4];
	void pdown(int o, int l, int r) {
		if (!t[o].tag)return;
		t[lch].tag += t[o].tag; t[rch].tag += t[o].tag;
		t[lch].mi += t[o].tag; t[rch].mi += t[o].tag;
		t[lch].mi2 += t[o].tag; t[rch].mi2 += t[o].tag;
		t[o].tag = 0;
	}
	void pup(int o) {
		t[o].mi = min(t[lch].mi, t[rch].mi);
		t[o].mi2 = min(t[lch].mi2, t[rch].mi2);
	}
	void build(int o, int l, int r) {
		t[o].tag = 0;
		if (l == r) {
			t[o].val = w+1 - l;
			t[o].mi = 0; t[o].mi2 = t[o].val;
			return;
		}
		build(lch, l, mid);
		build(rch, mid + 1, r);
		pup(o);
	}
	void upd(int o, int l, int r, int ql, int qr, int v) {
		if (ql <= l && r <= qr) {
			t[o].tag += v;
			t[o].mi += v;
			t[o].mi2 += v;
			return;
		}
		pdown(o, l, r);
		if (ql <= mid)upd(lch, l, mid, ql, qr, v);
		if (qr > mid) upd(rch, mid + 1, r, ql, qr, v);
		pup(o);
	}
	void upd2(int o, int l, int r, int ql, int qr, int v) {
		if (ql <= l && r <= qr) {
			t[o].mi = min((ll)v,t[o].mi);
			t[o].mi2 = t[o].val + t[o].mi;
			return;
		}
		pdown(o, l, r);
		if (ql <= mid)upd2(lch, l, mid, ql, qr, v);
		if (qr > mid) upd2(rch, mid + 1, r, ql, qr, v);
		pup(o);
	}
	ll qrymin(int o, int l, int r, int ql, int qr) {//l r 为o的左右孩子 ql, qr为操作区间 求最大值
		if (l > qr || r < ql)return 1e15;
		if (ql <= l && r <= qr)return t[o].mi;
		pdown(o, l, r);
		return min(qrymin(lch, l, mid, ql, qr), qrymin(rch, mid + 1, r, ql, qr));
	}
	ll qrymin2(int o, int l, int r, int ql, int qr) {//l r 为o的左右孩子 ql, qr为操作区间 求最大值
		if (l > qr || r < ql)return 1e15;
		if (ql <= l && r <= qr)return t[o].mi2;
		pdown(o, l, r);
		return min(qrymin2(lch, l, mid, ql, qr), qrymin2(rch, mid + 1, r, ql, qr));
	}
}st;

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef local
    freopen("in.txt", "r", stdin);
    int start = clock();
#endif
	cin >> h >> w;
	int now = 1;
	f(i, 1, 1e6)st.t[i].mi = st.t[i].mi2 = inf;
	st.build(1, 1, w);
	
	f(i, 1, h) {
		int a, b; cin >> a >> b;
		ll mi = st.qrymin2(1, 1, w, a, b)-(w-b);
		if(b+1<=w&&mi<inf)
		st.upd2(1, 1, w, b + 1,b+1, mi);
		st.upd(1, 1, w, a, b, inf);

		ll res = st.qrymin(1, 1, w, 1, w) + now;
		if (res >= inf) {
			cout << -1 << '\n';
		}
		else cout << res << '\n';
		now++;
	}

#ifdef local
    int end = clock();
    //cout << '\n' << end - start << "ms";
#endif* /
}

Measured memory_bytes: 34880