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

long long INFA = -1, INFB = (1 << 31) - 1;

class LazySegmentTreeA {
private:
	long long Size;
	vector<long long> Node, Lazy;
	vector<bool> Flag;
public:
	LazySegmentTreeA(long long N) {
		Size = 1;
		while (Size < N) Size <<= 1;
		Node.assign(Size * 2, INFA);
		Lazy.assign(Size * 2, INFA);
		Flag.assign(Size * 2, false);
	}
	void Eval(long long K, long long L, long long R) {
		if (Flag[K]) {
			Node[K] = Lazy[K];
			if (R - L > 1) {
				Lazy[K * 2] = Lazy[K];
				Flag[K * 2] = true;
				Lazy[K * 2 + 1] = Lazy[K];
				Flag[K * 2 + 1] = true;
			}
			Lazy[K] = INFA;
			Flag[K] = false;
		}
	}
	void Update(long long A, long long B, long long X, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return;
		if (A <= L && R <= B) {
			Lazy[K] = X;
			Flag[K] = true;
			Eval(K, L, R);
			return;
		}
		Update(A, B, X, K * 2, L, (L + R) / 2);
		Update(A, B, X, K * 2 + 1, (L + R) / 2, R);
		Node[K] = max(Node[K * 2], Node[K * 2 + 1]);
	}
	void Update(long long A, long long B, long long X) {
		Update(A, B, X, 1, 0, Size);
		return;
	}
	long long Query(long long A, long long B, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return INFA;
		if (A <= L && R <= B) return Node[K];
		return max(Query(A, B, K * 2, L, (L + R) / 2), Query(A, B, K * 2 + 1, (L + R) / 2, R));
	}
	long long Query(long long A, long long B) {
		return Query(A, B, 1, 0, Size);
	}
};

class LazySegmentTreeB {
private:
	long long Size;
	vector<long long> Node, Lazy;
	vector<bool> Flag;
public:
	LazySegmentTreeB(long long N) {
		Size = 1;
		while (Size < N) Size <<= 1;
		Node.assign(Size * 2, INFB);
		Lazy.assign(Size * 2, INFB);
		Flag.assign(Size * 2, false);
	}
	void Eval(long long K, long long L, long long R) {
		if (Flag[K]) {
			Node[K] = Lazy[K];
			if (R - L > 1) {
				Lazy[K * 2] = Lazy[K];
				Flag[K * 2] = true;
				Lazy[K * 2 + 1] = Lazy[K];
				Flag[K * 2 + 1] = true;
			}
			Lazy[K] = INFB;
			Flag[K] = false;
		}
	}
	void Update(long long A, long long B, long long X, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return;
		if (A <= L && R <= B) {
			Lazy[K] = X;
			Flag[K] = true;
			Eval(K, L, R);
			return;
		}
		Update(A, B, X, K * 2, L, (L + R) / 2);
		Update(A, B, X, K * 2 + 1, (L + R) / 2, R);
		Node[K] = min(Node[K * 2], Node[K * 2 + 1]);
	}
	void Update(long long A, long long B, long long X) {
		Update(A, B, X, 1, 0, Size);
		return;
	}
	long long Query(long long A, long long B, long long K, long long L, long long R) {
		Eval(K, L, R);
		if (B <= L || R <= A) return INFB;
		if (A <= L && R <= B) return Node[K];
		return min(Query(A, B, K * 2, L, (L + R) / 2), Query(A, B, K * 2 + 1, (L + R) / 2, R));
	}
	long long Query(long long A, long long B) {
		return Query(A, B, 1, 0, Size);
	}
};

int main() {
	int H, W;
	cin >> H >> W;
	W++;
	LazySegmentTreeA Seg1(W);
	LazySegmentTreeB Seg2(W);
	for (int i = 0; i < W; i++) Seg1.Update(i, i + 1, i), Seg2.Update(i, i + 1, 0);
	for (int i = 0; i < H; i++) {
		int A, B;
		cin >> A >> B;
		A--;
		long long NEXT = Seg1.Query(A, B + 1);
		Seg1.Update(A, B, INFA);
		Seg2.Update(A, B, INFB);
		if (NEXT != -1) {
			Seg1.Update(B, B + 1, NEXT);
			Seg2.Update(B, B + 1, B - NEXT);
		}
		long long ANS = Seg2.Query(0, W - 1);
		if (ANS == INFB) cout << -1 << endl;
		else cout << ANS + i + 1 << endl;
	}
}

Measured memory_bytes: 19752