using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var ST = new SegTree(W + 1);
		for(int i=0;i<W;i++) ST.Update(i, 0);
		
		int[] ans = new int[H];
		for(int i=0;i<H;i++){
			while(true){
				var idx = ST.QueryMinIdx(A[i], B[i] + 1);
				var val = ST.At(idx);
				if(val == ST.Inf) break;
				int hor = B[i] + 1 - idx;
				if(ST.At(B[i] + 1) > val + hor) ST.Update(B[i] + 1, val + hor);
				ST.ClearAt(idx);
			}
			var minhor = ST.QueryMin(0, W);
			ans[i] = minhor == ST.Inf ? -1 : (minhor + i + 1);
		}
		
		Console.WriteLine(String.Join("\n", ans));
		
	}
	
	int H,W;
	int[] A,B;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1];
		A = new int[H];
		B = new int[H];
		for(int i=0;i<H;i++){
			d = ria();
			A[i] = d[0] - 1; B[i] = d[1] - 1;
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}



class SegTree{
	//segment Tree 
	// 0-origin
	public int[] Data;	
	public int[] Idx;	
	public int Inf;	
	public int N;		//size 
	public int n;		//size (power of 2);
	
	// constructor
	public SegTree(int n_, int inf_){
		N=n_;Inf = inf_;
		n = 1;
		while(n < n_) n *= 2;
		Data = new int[2*n - 1];
		Idx = new int[2*n - 1];
		for(int i=0;i<2*n-1;i++) Data[i] = Inf;
	}
	public SegTree(int n_){
		N = n_; Inf = (int) 1e9;
		n = 1;
		while(n < n_) n *= 2;
		Data = new int[2*n - 1];
		Idx = new int[2*n - 1];
		for(int i=0;i<2*n-1;i++) Data[i] = Inf;
	}
	
	//	   0
	//	 1   2
	//	3 4 5 6
	public void Update(int k, int a){
		k+=n-1;	
		Data[k]=a;
		Idx[k] = k - (n - 1);
		while(k>0){
			k=(k-1)/2;
			Data[k] = Math.Min(Data[k*2+1], Data[k*2+2]);
			Idx[k] = Data[k*2+1] < Data[k*2+2] ? Idx[k*2+1] : Idx[k*2+2];
		}
	}
	
	
	
	//RMQ;
	//	[a,b) 
	//	call: Query(a,b,0,0,n) 
	public int QueryMin(int a, int b){
		return Query(a, b, 0, 0, n);
	}
	public int QueryMinIdx(int a, int b){
		return QueryIdx(a, b, 0, 0, n);
	}
	public int At(int idx){
		return Data[idx + n - 1];
	}
	public void ClearAt(int idx){
		Update(idx, Inf);
	}
	
	public int Query(int a,int b,int k,int l,int r){
		// [a,b) not overwraps [l,r) => return Inf
		if(r<=a || b<=l) return Inf;
		// [a,b) include [l,r) => return Data[k];
		if(a<=l && r<=b)return Data[k];
		// or return min(left,right)
		var vl = Query(a,b,k*2+1,l,(l+r)/2);
		var vr = Query(a,b,k*2+2,(l+r)/2,r);
		return Math.Min(vl,vr);
	}
	public int QueryIdx(int a,int b,int k,int l,int r){
		// [a,b) not overwraps [l,r) => return Inf
		if(r<=a || b<=l) return -1;
		// [a,b) include [l,r) => return Data[k];
		if(a<=l && r<=b)return Idx[k];
		// or return min(left,right)
		var vlidx = QueryIdx(a,b,k*2+1,l,(l+r)/2);
		var vridx = QueryIdx(a,b,k*2+2,(l+r)/2,r);
		var vl = Data[vlidx + n - 1];
		var vr = Data[vridx + n - 1];
		return vl < vr ? vlidx : vridx;
	}
	
	
	public int Min{
		get{ return Data[0]; }
	}
	public int MinIdx{
		get{ return Idx[0]; }
	}
	
	public void UniqInit(int val){
		for(int i=0+n-1;i<N+n-1;i++) Data[i] = val;
		int l = n-1; int r = N+n-1-1;
		while(l > 0){
			l = (l-1)/2; r = (r-1)/2;
			for(int i=l;i<=r;i++) Data[i] = val;
		}
	}
	public void UniqInit(int[] vs){
		for(int i=0+n-1;i<N+n-1;i++) {
			Data[i] = vs[i-(n-1)];
			Idx[i] = i - (n-1);
		}
		for(int i=n-2;i>=0;i--){
			Data[i] = Math.Min(Data[2*i+1],Data[2*i+2]);
			Idx[i] = Data[2*i+1] < Data[2*i+2] ? Idx[2*i+1] : Idx[2*i+2];
		}
	}
	
	public void Dump(){
		Console.WriteLine();
		int h = 0;
		int cnt = 0;
		for(int i=0;i<Data.Length;i++){
			Console.Write("{0} ",Data[i]);
			cnt++;
			if(cnt == 1<<h){
				cnt = 0;
				h++; 
				Console.WriteLine();
			}
		}
	}
	
}


Measured memory_bytes: 54716