#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
const ll maxn = 3e5+100;
const ll mod=998244353;

ll st[4*maxn];
ll st1[4*maxn];
ll la1[4*maxn];
ll la[4*maxn];
ll h, n;
void dosth(ll id,ll left,ll right)
{
    if (left!=right)
    {
        st[id*2]+=la[id];
        st[id*2+1]+=la[id];
        la[id*2]+=la[id];
        la[id*2+1]+=la[id];
        la[id]=0;
    }
}
void update(ll id,ll left,ll right,ll x,ll y,ll diff)
{
    dosth(id,left,right);
    if (x>right||y<left)
        return ;
    if (x<=left&&y>=right)
    {
        st[id]+=diff;
        la[id]+=diff;
        dosth(id,left,right);
        return ;

    }
    ll mid=(left+right) /2;
    update(id*2,left,mid, x, y,diff);
    update(id*2+1, mid+1, right, x, y,diff);
    st[id]=min(st[id*2],st[id*2+1]);

}
void update3(ll id,ll left,ll right,ll x,ll diff)
{
    dosth(id,left,right);
    if (x>right||x<left)
        return ;
    if (left==right)
    {
        st[id]=diff;
        return ;

    }
    ll mid=(left+right) /2;
    update3(id*2,left,mid, x,diff);
    update3(id*2+1, mid+1, right, x,diff);
    st[id]=min(st[id*2],st[id*2+1]);

}
ll get(ll id,ll left,ll right,ll x,ll y)
{
    dosth(id,left,right);
    if (x>right||y<left)
        return 1e13;
        if (x<=left&&y>=right)
        {
            return st[id];

        }
    ll mid=(left+right) /2;
   return min(get(id*2,left,mid, x, y ), get(id*2+1,mid+1, right, x, y));
}

// doan xu li 1 2 3 4 .. n
void dosth1(ll id,ll left,ll right)
{
    if (left!=right)
    {
        st1[id*2]+=la1[id];
        st1[id*2+1]+=la1[id];
        la1[id*2]+=la1[id];
        la1[id*2+1]+=la1[id];
        la1[id]=0;
    }
}
void build(ll id,ll left,ll right)
{
    if (left==right)
    {
        st1[id]=left;
        return ;
    }
    ll mid=(left+right) /2;
    build(id*2, left,mid);
    build(id*2+1, mid+1,right);
    st1[id]=max(st1[id*2],st1[id*2+1]);


}
void update1(ll id,ll left,ll right,ll x,ll diff)
{
    dosth1(id,left,right);
    if (x>right||x<left)
        return ;
    if (left==right)
    {
        st1[id]=diff;
        return ;
    }
    ll mid=(left+right) /2;
    update1(id*2,left,mid, x,diff);
    update1(id*2+1, mid+1, right, x,diff);
    st1[id]=max(st1[id*2],st1[id*2+1]);
}
void update2(ll id,ll left,ll right,ll x, ll y,ll diff)
{
   dosth1(id,left, right);
   if (x>right||y<left) return ;
   if (x<=left&&y>=right)
   {
      st1[id]+=diff;
      la1[id]+=diff;
     dosth1(id,left,right);
     return ;
   }
   ll mid=(left+right) /2;
   update2(id*2,left, mid, x, y ,diff);
   update2(id*2+1, mid+1 ,right, x, y,diff);
    st1[id]=max(st1[id*2],st1[id*2+1]);
}
ll get1(ll id,ll left,ll right,ll x, ll y)
{
   dosth1(id,left, right);
   if (x>right||y<left) return -1e13;
   if (x<=left&&y>=right)
   {
       return st1[id];
   }
   ll mid=(left+right) /2;
   return max(get1(id*2,left,mid,x,y),get1(id*2+1,mid+1, right, x, y));

}
int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("test.txt", "r", stdin);
    if (fopen("cnt-mst.inp","r"))
    {
        freopen("cnt-mst.inp","r", stdin);
        freopen("cnt-mst.out", "w",stdout);
    }

    cin>> h>> n;
    build(1,1,n);

    for (int i=1; i<=h; i++)
    {
        ll x, y;
        cin>>x>>y;
        ll h2= get1(1,1,n,x,y);
        //cout <<h2<<endl;
        update2(1,1,n, x,y,-1e13);
        update(1,1,n,x,y,1e13);

            if (y!=n)
            {
                ll p = get1(1,1,n,y+1,y+1);
                if (p<h2)
                {

                update1(1,1,n,y+1,h2);
                update3(1,1,n,y+1,y+1-h2);
                }
            }


        ll ans=get(1,1,n,1,n);
        if (ans>h+n)
        {
            cout <<-1<<endl;
        }
        else
        {
            cout <<ans+i<<endl;
        }

    }








}


Measured memory_bytes: 19976