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>
#define ri register
#define int long long
#define E (n+1)
using namespace std; const int N=500010, Mod=1e9+7;
inline int read()
{
    int s=0, w=1; ri char ch=getchar();
    while(ch<'0'||ch>'9') { if(ch=='-') w=-1; ch=getchar(); }
    while(ch>='0'&&ch<='9') s=(s<<3)+(s<<1)+(ch^48), ch=getchar();
    return s*w;
}
int h,w;
multiset<int> Q; map<int,int> f;
#define gg map<int,int>::iterator
signed main()
{
    h=read(), w=read();
    for(ri int i=0;i<w;i++) f[i]=i, Q.insert(0);
    for(ri int i=0;i<h;i++)
    {
        int L,R;
        L=read(), R=read();
        gg qwq=f.lower_bound(L-1);
        int pc=-1;
        while(qwq!=f.end()&&(qwq->first)<=R)
        {
            pc=max(pc,qwq->second);
            Q.erase(Q.find(qwq->first-qwq->second));
            f.erase(qwq++);
        }
        if((~pc) && R^w)
        {
            Q.insert(R-pc);
            f[R]=pc;
        }
        if(Q.empty()) puts("-1");
        else printf("%lld\n",i+1+(*Q.begin()));
    }
    return 0;
}