#include<bits/stdc++.h>
using namespace std ;

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

const int N = 200005;

ll h,w;
ll A[N],B[N];


struct node
{
    ll minimum;
}fake={INF};
struct lz
{
    ll add =0;
    ll ax =0;
};
struct SEGTREE
{
    ll a[N];
    SEGTREE(){ mem0(a); }
    node tree[4*N];
    lz lazy[4*N];
    inline node combine(node a,node b)
    {
        node ret;
        ret.minimum=min(a.minimum,b.minimum);
        return ret;
    }
    inline node make_node(ll val)
    {
        node ret;
        ret.minimum=val;
        return ret;
    }
    inline void pushdown(ll v,ll st,ll en)
    {
        if(lazy[v].ax==0)
            tree[v].minimum += lazy[v].add;
        else
            tree[v].minimum = lazy[v].add+lazy[v].ax;
        ll u = lazy[v].add;
        ll mid = (st+en)/2;
        if(st!=en)
        {
            if(lazy[v].ax==0)
                lazy[v<<1].add+=u,lazy[v<<1|1].add+=u;
            else
            {
                lazy[v<<1]=lazy[v];
                lazy[v<<1|1]=lazy[v];
                lazy[v<<1|1].ax = lazy[v].ax+(mid-st)+1;
            }
        }
        lazy[v].ax=0,lazy[v].add=0;
        return ;
    }
    void buildTree(ll v,ll st,ll en)
    {
        if(st==en)
        {
            tree[v]=make_node(a[st]);
            return ;
        }
        ll mid=(st+en)>>1;
        buildTree(v<<1,st,mid);
        buildTree(v<<1 | 1,mid+1,en);
        tree[v]=combine(tree[v<<1],tree[v<<1 | 1]);
    }
    void rupdate(ll v,ll st,ll en,ll l,ll r,ll val)
    {
        if(lazy[v].add!=0 || lazy[v].ax!=0)
        {
            pushdown(v,st,en);
        }
        if(en<l || st>r)return ;
        if(st>=l && en<=r)
        {
            lazy[v].add=val;
            pushdown(v,st,en);
            return ;
        }
        ll mid=(st+en)>>1;
        rupdate(v<<1,st,mid,l,r,val);
        rupdate(v<<1 | 1,mid+1,en,l,r,val);
        tree[v]=combine(tree[v<<1],tree[v<<1 | 1]);
    }
    void rupdate2(ll v,ll st,ll en,ll l,ll r,ll idx,ll val)
    {
        if(lazy[v].add!=0 || lazy[v].ax!=0)
        {
            pushdown(v,st,en);
        }
        if(en<l || st>r)return ;
        if(st>=l && en<=r)
        {
            lazy[v].ax=val+(st-idx);
            lazy[v].add=0;
            pushdown(v,st,en);
            return ;
        }
        ll mid=(st+en)>>1;
        rupdate2(v<<1,st,mid,l,r,idx,val);
        rupdate2(v<<1 | 1,mid+1,en,l,r,idx,val);
        tree[v]=combine(tree[v<<1],tree[v<<1 | 1]);
    }
    node query(ll v,ll st,ll en,ll l,ll r)
    {
        if(en<l || st>r)
            return fake;
        if(lazy[v].add!=0 || lazy[v].ax!=0)
        {
            pushdown(v,st,en);
        }
        if(st>=l && en<=r)
            return tree[v];
        ll mid=(st+en)>>1;
        return combine(query(v<<1,st,mid,l,r),query(v<<1 | 1,mid+1,en,l,r));
    }
}seg;

int _runtimeTerror_()
{
    cin>>h>>w;
    for(int i=1;i<=h;++i)
        cin>>A[i]>>B[i];
    bool neg = false;
    for(int i=1;i<=w;++i)
        seg.a[i]=0;
    seg.buildTree(1,1,w);
    for(int i=1;i<=h;++i)
    {
        if(neg)
        {
            cout<<"-1\n";continue;
        }
        seg.rupdate(1,1,w,1,w,1);
        node u = seg.query(1,1,w,A[i]-1,A[i]-1);
        seg.rupdate2(1,1,w,A[i],B[i],A[i],u.minimum+1);
        //cout<<"u "<<u.minimum+1<<"\n";
        node ans = seg.query(1,1,w,1,w);
        if(ans.minimum>=INF)
        {
            cout<<"-1\n";
            neg=true;
            continue;
        }
        cout<<ans.minimum<<"\n";
        //cout<<seg.query(1,1,w,4,4).minimum;
    }

    return 0;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifdef runSieve
        sieve();
    #endif
    #ifdef NCR
        initialize();
    #endif
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--)
        _runtimeTerror_();
    return 0;
}

Measured memory_bytes: 24844