#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define fillarray(array, value, begin, end) fill((array) + (begin), (array) + (end) + 1, value)
#define fillvector(v, value) fill((v).begin(), (v).end(), value)
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
#define vecfirst (*vec.begin())
#define veclast (*vec.rbegin())
#define vecall(v) (v).begin(), (v).end()
#define vecupsort(v) (sort((v).begin(), (v).end()))
#define vecdownsort(v, type) (sort(vecall(v), greater<type>()))
#define veccmpsort(v, cmp) (sort(vecall(v), cmp))
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll llinf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
clock_t TIME__START, TIME__END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME__END - TIME__START) / 1000);
    system("pause");
#endif
}
int h, w;
int A[N], B[N], cnt[N];
map<int, int> c;

inline void solve()
{
    scanf("%d%d", &h, &w);
    for (int i = 1; i <= h; ++i)
        scanf("%d%d", &A[i], &B[i]);
    for (int i = 1; i <= w; ++i)
        c.insert(mp(i, i));
    int ans = 0;
    cnt[0] = w;
    for (int i = 1; i <= h; ++i)
    {
        int L = A[i], R = B[i];
        auto it = c.lower_bound(L);
        int pos = 0;
        while (it != c.end() && it->first <= R + 1)
        {
            pos = max(pos, it->second);
            cnt[it->first - it->second]--;
            it = c.erase(it);
        }
        if (pos && R + 1 <= w)
        {
            cnt[R + 1 - pos]++;
            c.insert(mp(R + 1, pos));
        }
        while (!cnt[ans] && ans < w)
            ans++;
        if (ans == w)
            puts("-1");
        else
            printf("%d\n", ans + i);
    }
}

int main()
{
    TIME__START = clock();
    int Test = 1;
    // scanf("%d", &Test);
    while (Test--)
        solve();
    TIME__END = clock();
    program_end();
    return 0;
}
#include <bits/stdc++.h>
using namespace std;

/*

dp[i][j]=dp[i-1][j]+1; (j<L[i-1] or R[i-1]<j)
dp[i][j]=dp[i-1][L[i-1]-1]+1+(j-(L[i-1]-1)) (L[i-1]<=j<=R[i-1])
*/

const int M=2e5+5;
const int INF=0x3f3f3f3f;

struct SegT
{
	struct TN
	{
		int mn,fi,add;
		void app_add(int v)
		{
			add+=v;
			mn+=v;
		}
		void app_set(int v) // arthimic
		{
			add=0;
			fi=v;
			mn=v;
		}
	}tn[M*4];
	int P,L,R,V;
	void push(int o,int l,int mi,int r)
	{
		if(tn[o].fi!=-1)
		{
			tn[o<<1].app_set(tn[o].fi);
			tn[o<<1|1].app_set(tn[o].fi+mi-l+1);
			tn[o].fi=-1;
		}
		if(tn[o].add)
		{
			tn[o<<1].app_add(tn[o].add);
			tn[o<<1|1].app_add(tn[o].add);
			tn[o].add=0;
		}
	}
	void pull(int o)
	{
		tn[o].mn=min(tn[o<<1].mn,tn[o<<1|1].mn);
	}
	void build(int o,int l,int r)
	{
		tn[o].mn=tn[o].add=0;
		tn[o].fi=-1;
		if(l==r)
		{
			if(l==0) tn[o].mn=tn[o].add=INF;
			return;
		}
		int mid=(l+r)>>1;
		build(o<<1,l,mid);
		build(o<<1|1,mid+1,r);
		pull(o);
	}
	void add(int o,int l,int r)
	{
		if(L<=l&&r<=R)
		{
			tn[o].app_add(1);
			return;
		}
		int mid=(l+r)>>1;
		push(o,l,mid,r);
		if(L<=mid) add(o<<1,l,mid);
		if(mid<R) add(o<<1|1,mid+1,r);
		pull(o);
	}
	void set(int o,int l,int r)
	{
		if(L<=l&&r<=R)
		{
			tn[o].app_set(V+l-L+1);
			return;
		}
		int mid=(l+r)>>1;
		push(o,l,mid,r);
		if(L<=mid) set(o<<1,l,mid);
		if(mid<R) set(o<<1|1,mid+1,r);
		pull(o);
	}
	int query(int o,int l,int r)
	{
		if(l==r) return tn[o].mn;
		int mid=(l+r)>>1;
		push(o,l,mid,r);
		if(P<=mid) return query(o<<1,l,mid);
		else return query(o<<1|1,mid+1,r);
	}
}segt;

int main()
{
	int h,w; scanf("%d%d",&h,&w);
	segt.build(1,0,w);
	int l,r;
	for(int i=0;i<h;i++)
	{
		scanf("%d%d",&l,&r);
		if(l!=1)
		{
			segt.L=1; segt.R=l-1;
			segt.add(1,0,w);
		}
		if(r!=w)
		{
			segt.L=r+1; segt.R=w;
			segt.add(1,0,w);
		}
		segt.P=l-1;
		segt.V=segt.query(1,0,w);
		segt.L=l; segt.R=r;
		segt.set(1,0,w);
		int ans=segt.tn[1].mn;
		printf("%d\n",ans>=INF ? -1 : ans);
	}
	return 0;
}