#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 10;
const ll mod = 1e9 + 7;
int n, m;
int l[N], r[N];
multiset<int>mst;
typedef pair<int, int>pii;
set<pii>st;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++)scanf("%d%d", &l[i], &r[i]);
	for (int i = 1; i <= m; i++)st.insert({ i,i }), mst.insert(0);
	for (int i = 1; i <= n; i++) {
		auto it = st.lower_bound({ l[i],0 });
		int tmp = 0;
		while (it != st.end() && (*it).first <= r[i]) {
			tmp = max(tmp, (*it).second);
			mst.erase(mst.find((*it).first - (*it).second));
			it = st.erase(it);
		}
		if (tmp) {
			st.insert({ (r[i] + 1 <= m ? r[i] + 1 : INF),tmp });
			mst.insert((r[i] + 1 <= m ? r[i] + 1 : INF) - tmp);
		}
		int ans = *mst.begin();
		printf("%d\n", ans < m ? ans + i : -1);
	}
	return 0;
}