Problem: There is a grid of squares with H+1 horizontal rows and W vertical columns.

You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H, you cannot move down from the A_i-th, (A_i + 1)-th, \ldots, B_i-th squares from the left in the i-th row from the top.

For each integer k from 1 through H, find the minimum number of moves needed to reach one of the squares in the (k+1)-th row from the top. (The starting square can be chosen individually for each case.) If, starting from any square in the top row, none of the squares in the (k+1)-th row can be reached, print `-1` instead.

Constraints

* 1 \leq H,W \leq 2\times 10^5
* 1 \leq A_i \leq B_i \leq W

Input

Input is given from Standard Input in the following format:


H W
A_1 B_1
A_2 B_2
:
A_H B_H


Output

Print H lines. The i-th line should contain the answer for the case k=i.

Example

Input

4 4
2 4
1 1
2 3
2 4


Output

1
3
6
-1

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
const int N=2e5+11,M=N<<2,oo=~0u>>2;
int n,m,mn[M],z[M],t[M],g[M];
int ql,qr,qx;
void pu(int x){
	z[x]=z[x*2];
	t[x]=t[x*2+1];
	mn[x]=min(mn[x*2],mn[x*2+1]);
}
void build(int x,int l,int r){
	if(l==r){
		z[x]=l;
		t[x]=l;
		return;
	}
	int m=l+r>>1;
	build(x*2,l,m);
	build(x*2+1,m+1,r);
	pu(x);
}
void pt(int x,int w,int r){
	g[x]=w;
	t[x]=w;
	z[x]=w;
	if(w<=m)mn[x]=w-r;
	else mn[x]=oo;
}
void upd(int x,int l,int r){
	if(z[x]>qr||t[x]<ql)return;
	if(z[x]>=ql&&t[x]<=qr){
		pt(x,qr+1,r);
		return;
	}
	int m=l+r>>1;
	if(g[x]){
		pt(x*2,g[x],m);
		pt(x*2+1,g[x],r);
		g[x]=0;
	}
	upd(x*2,l,m);
	upd(x*2+1,m+1,r);
	pu(x);
}
int main(){
	cin>>n>>m;
	int i;
	build(1,1,m);
	int p=1;
	for(i=1;i<=n;++i){
		cin>>ql>>qr;
		upd(1,1,m);
		if(mn[1]>m)puts("-1");
		else printf("%d\n",mn[1]+i);
	}
}