using namespace std;

//#define fileio

#ifndef fileio
#include <iostream>
#endif
#include <fstream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <assert.h>
#include <functional>
#include <math.h>
#include <string>
#include <ctime>

typedef long long ll;

#ifdef fileio
ifstream cin;
ofstream cout;
#endif


struct segt {
	vector<ll> t, mn, mn2, lazyby, lazyto;
	vector<bool> set;
	vector<int> l, r;


	void build(int i, int j, int v) {
		l[v] = i, r[v] = j;
		t[v] = lazyby[v] = lazyto[v] = 0;
		mn[v] = 0;
		mn2[v] = -j;
		if (i == j) return;
		build(i, (i + j) / 2, v * 2);
		build((i + j) / 2 + 1, j, v * 2 + 1);
	}

	segt() {}
	segt(int n) {
		mn.resize(4 * n), t.resize(4 * n), lazyby.resize(4 * n), lazyto.resize(4 * n);
		mn2.resize(4 * n);
		l.resize(4 * n), r.resize(4 * n);
		set.resize(4 * n, false);
		build(0, n - 1, 1);
	}
	segt(vector<ll> v) {
		int n = v.size();
		mn.resize(4 * n), t.resize(4 * n), lazyby.resize(4 * n), lazyto.resize(4 * n);
		mn2.resize(4 * n);
		l.resize(4 * n), r.resize(4 * n);
		set.resize(4 * n, false);
		build(0, n - 1, 1);
		for (int i = 0; i < v.size(); i++) {
			updateby(i, i, v[i]);
		}
	}

	inline void prop(int v) {
		if (l[v] != r[v]) {
			if (set[v]) {
				lazyby[2 * v] = lazyby[2 * v + 1] = 0;
				lazyto[2 * v] = lazyto[2 * v + 1] = lazyto[v];
				set[2 * v] = set[2 * v + 1] = true;
			}
			lazyby[2 * v] += lazyby[v];
			lazyby[2 * v + 1] += lazyby[v];
		}
		if (set[v]) {
			t[v] = lazyto[v] * (r[v] - l[v] + 1);
			mn[v] = lazyto[v];
			mn2[v] = lazyto[v] - r[v];
		}
		t[v] += lazyby[v] * (r[v] - l[v] + 1);
		mn[v] += lazyby[v];
		mn2[v] += lazyby[v];
		set[v] = lazyby[v] = lazyto[v] = 0;
	}

	void update(int i, int j, ll val, bool by, int v) {
		if (j < l[v] || r[v] < i) return;
		if (i <= l[v] && r[v] <= j) {
			prop(v);
			if (by) lazyby[v] += val;
			else {
				lazyto[v] = val;
				set[v] = true;
			}
			prop(v);
			return;
		}
		prop(v);
		update(i, j, val, by, 2 * v);
		update(i, j, val, by, 2 * v + 1);
		prop(2 * v);
		prop(2 * v + 1);
		t[v] = t[2 * v] + t[2 * v + 1];
		mn[v] = min(mn[2 * v], mn[2 * v + 1]);
		mn2[v] = min(mn2[2 * v], mn2[2 * v + 1]);
	}

	void updateby(int i, int j, int val) { update(i, j, val, true, 1); }
	void updateto(int i, int j, int val) { update(i, j, val, false, 1); }


	ll query(int i, int j, int m, int v) {
		if (j < l[v] || r[v] < i) {
			if (m) return 1000000000;
			return 0;
		}
		prop(v);
		if (i <= l[v] && r[v] <= j) {
			if (m == 1) return mn[v];
			if (m == 2) return mn2[v];
			return t[v];
		}
		ll l = query(i, j, m, 2 * v);
		ll r = query(i, j, m, 2 * v + 1);
		if (m) return min(l, r);
		return l + r;
	}

	ll querysum(int i, int j) { return query(i, j, false, 1); }
	ll querymin(int i, int j) { return query(i, j, 1, 1); }
};

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#ifdef fileio
    cin.open("Text.txt");
    cout.open("Output.txt");
#endif
	int h, w;
	cin >> h >> w;
	segt s(w);
	for (int i = 0; i < h; i++) {
		int x, y;
		int ans;
		cin >> x >> y;
		x--;
		y--;
		ll z = s.query(x, y, 2, 1);

		if (y != w - 1) s.updateto(y + 1, y + 1, min(y + 1 + z, s.querymin(y+1, y+1)));
		s.updateto(x, y, 10000000);
		ans = s.querymin(0, w-1);

		if (ans >= 10000000) cout << -1 << endl;
		else cout << ans + i+1 << endl;
	}

}


Measured memory_bytes: 40948