#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifdef APURBA
#define HERE cout<<"here - "<<__LINE__<<"\n";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout<<endl;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << " ";
    err(++it, args...);
}
#else
#define HERE
#define debug(args...)
#endif
const ll mod = 1e9+7 ;
const int N = 2e5+5;
typedef pair<ll,ll> pii;
const ll inf = 1e18;

ll t[N*4], lazy1[N*4], lazy2[N*4] , lazy3[N*4];
bool flag[N*4];
void push_down(ll node, ll l, ll r)
{
    if(flag[node])
    {
        t[node*2]= lazy3[node];
        t[node*2+1]=lazy3[node];
        lazy3[node*2]= lazy3[node];
        lazy3[node*2+1] = lazy3[node];
        lazy3[node] =0;
        lazy1[node*2] = 0;
        lazy1[node*2+1]=0;
        lazy2[node*2] =0;
        lazy2[node*2+1]=0;
        flag[node*2]=true;
        flag[node*2+1]=true;
        flag[node]=false;
    }
    if(lazy1[node])
    {
        t[node*2]+= lazy1[node];
        t[node*2+1]+=lazy1[node];
        lazy1[node*2]+= lazy1[node];
        lazy1[node*2+1] += lazy1[node];
        lazy1[node] =0 ;
    }
    if(lazy2[node])
    {
        ll mid = (l+r)/2;
        ll l1 = l , r1 = mid, l2 = mid+1 ,r2 = r;
        t[node*2]+= l1*lazy2[node];
        t[node*2+1] += l2*lazy2[node];
        lazy2[node*2]+= lazy2[node];
        lazy2[node*2+1] += lazy2[node];
        lazy2[node]=0;
    }
}

void update1(ll node, ll l, ll r, ll i, ll j, ll val)
{
    if(r<l || r<i || l>j)
        return;
    if(l>=i && r<=j)
    {
        t[node]+=  val;
        lazy1[node]+=val;
        return;
    }
    push_down(node,l,r);
    ll mid= (l+r)/2;
    update1(node*2, l, mid, i, j,val);
    update1(node*2+1, mid+1, r, i, j, val);
    t[node] = min(t[node*2], t[node*2+1]);
}
void update3(ll node, ll l, ll r, ll i, ll j, ll val)
{
    if(r<l || r<i || l>j)
        return;
    if(l>=i && r<=j)
    {
        t[node]=  val;
        lazy3[node]=val;
        flag[node]=true;
        lazy2[node]=0;
        lazy1[node]=0;
        return;
    }
    push_down(node,l,r);
    ll mid= (l+r)/2;
    update3(node*2, l, mid, i, j,val);
    update3(node*2+1, mid+1, r, i, j, val);
    t[node] = min(t[node*2], t[node*2+1]);
}
void update2(ll node, ll l, ll r , ll i, ll j)
{
    if(r<l || r<i || l>j)
        return;
    if(l>=i && r<=j)
    {
        t[node]+=  l;
        lazy2[node]++;
        return;
    }
    push_down(node,l,r);
    ll mid= (l+r)/2;
    update2(node*2 , l , mid , i, j);
    update2(node*2+1 , mid+1 , r, i, j);
    t[node] = min(t[node*2], t[node*2+1]);
}

ll query(ll node, ll l, ll r, ll i, ll j)
{
    if(r<l|| r<i || l>j)
        return inf;
    if(l>=i && r<=j)
    {
        return t[node];
    }
    push_down(node,l,r);
    ll mid= (l+r)/2;
    ll x =query(node*2, l, mid, i, j);
    ll y =query(node*2+1, mid+1, r, i, j);
    return min(x,y);
}
ll n,m;
ll get_val(ll i)
{
    cout<<query(1,1,m,i,i)<<" ";
}
void TEST_CASES(int cas)
{
    scanf("%lld %lld",&n,&m);
    vector<pii>a(n);
    for(ll i=0; i<n; i++)
    {
        scanf("%lld %lld",&a[i].first,&a[i].second);
    }
    for(ll i=1; i<=n; i++)
    {
        if(a[i-1].first-1>=1)
            update1(1,1,m,1,a[i-1].first-1,1);
        if(a[i-1].second+1 <=m)
            update1(1,1,m,a[i-1].second+1,m,1);
        ll val = inf;
        if(a[i-1].first-1 >=1)
        {
            val = query(1,1,m,a[i-1].first-1,a[i-1].first-1);
            update3(1,1,m,a[i-1].first, a[i-1].second,val-a[i-1].first+1 );
            update2(1,1,m,a[i-1].first , a[i-1].second);
        }
        else{
            update3(1,1,m,a[i-1].first, a[i-1].second,inf );
        }

        //
//        HERE;
//        for(ll j=1;j<=m;j++)
//        {
//            get_val(j);
//        }
//        cout<<endl;
//        HERE;
        ll ans = query(1,1,m,1,m);
        if(ans>=1e16)
            ans = -1;
        printf("%lld\n",ans);
    }

}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}



Measured memory_bytes: 23436