#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

class SegTree
{
    private:
        int _n;
        int _d;

        class SNode
        {
            public:
                int _min;
                int _value;
                bool _last;
                bool _used;

                SNode()
                {
                    _min = 0;
                    _value = 0;
                    _last = false;
                    _used = false;
                }

                SNode(SNode &t)
                {
                    set(t);
                }

                void set(SNode &t)
                {
                    _min = t._min;
                    _value = t._value;
                    _used = t._used;
                    _last = t._last;
                }


                void set(int v)
                {
                    _value = v;
                    _used = true;
                    _last = true;
                }
        };

        SNode* nodes;

        int dindex(int d)
        {
            return (1 << d);
        }

        void evalnode(int index)
        {
            if( index < 1 ) return;
            nodes[index]._last = false;
            if( nodes[index * 2]._used && nodes[index * 2 + 1]._used )
            {
                nodes[index]._min = min(nodes[index * 2]._min, nodes[index * 2 + 1]._min);
                nodes[index]._used = true;
            }
            else if( nodes[index * 2]._used )
            {
                nodes[index].set(nodes[index * 2]);
            }
            else if( nodes[index * 2 + 1]._used )
            {
                nodes[index].set(nodes[index * 2 + 1]);
            }

            if( nodes[index]._used ) evalnode(index / 2);
        }

        // 対象ノードが範囲に含まれるか　-1: 含まれない、　0:部分的に含まれる、1:完全に含む
        int check(int l, int r, int index, int d)
        {
            int i = index - (1 << d);
            int k = ( 1 << ( _d - d - 1) );
            if( r <= i * k || l >= (i + 1) * k ) return -1;
            if( l <= i * k && r >= (i + 1) * k ) return 1;
            return 0;
        }

        int getleft(int index, int d)
        {
            int i = index - (1 << d);
            int k = ( 1 << ( _d - d - 1) );
            return i * k;
        }

        int getminsub(int l, int r, int index, int d)
        {
            if( d == _d - 1 ) nodes[index]._min;
            if( check(l, r, index, d) == 1 ) return nodes[index]._min;
            if( nodes[index]._last )
            {
                int il = getleft(index, d);
                if( l > il )
                {
                    return l - nodes[index]._value;
                }
                else
                {
                    return nodes[index]._min;
                }
            }

            if( check(l, r, index * 2, d + 1) == -1 ) return getminsub(l, r, index * 2 + 1, d + 1);
            if( check(l, r, index * 2 + 1, d + 1) == -1 ) return getminsub(l, r, index * 2, d + 1);
            return min(getminsub(l, r, index * 2 + 1, d + 1), getminsub(l, r, index * 2, d + 1));
        }

        int getsub(int l, int index, int d)
        {
            if( d == _d - 1 ) return nodes[index]._value;
            if( nodes[index]._last ) return nodes[index]._value;
            if( l < getleft(index * 2 + 1, d + 1)) return getsub(l, index * 2, d + 1);
            return getsub(l, index * 2 + 1, d + 1);
        }


        void setrangesub(int l, int r, int index, int d, int v)
        {
            if( d == _d - 1 )
            {
                int i = index - dindex(_d - 1);
                nodes[index].set(v);
                nodes[index]._min = i - v;    
                return;            
            }
            int ret = check(l, r, index, d);
            if( ret < 0 ) return;
            if( check(l, r, index, d) == 1 ) 
            {
                setnode(index, d, v);
            }
            else
            {
                if( nodes[index]._last )
                {
                    int _pre = nodes[index]._value;
                    int i = index - (1 << d);
                    int k = ( 1 << ( _d - d - 1) );

                    nodes[index]._last = false;
                                        
                    setrangesub(i * k, (i + 1) * k, index * 2, d + 1, _pre);
                    setrangesub(i * k, (i + 1) * k, index * 2 + 1, d + 1, _pre);
                }
                if( check(l, r, index * 2, d + 1) != -1 ) setrangesub(l, r, index * 2, d + 1, v);
                if( check(l, r, index * 2 + 1, d + 1) != -1 ) setrangesub(l, r, index * 2 + 1, d + 1, v);

                nodes[index]._min = min(nodes[index * 2]._min, nodes[index * 2 + 1]._min);
            }            
        }

        void setnode(int index, int d, int v)
        {
            nodes[index].set(v);
            int no = index - dindex(d);
            int td = d;
            while( td < _d - 1 )
            {
                no *= 2;
                td++;
            }
            nodes[index]._min = no - v;
            nodes[index]._last = true;
        }



    public:
        SegTree(int n)
        {
            _n = n;
            _d = 1;
            int bit = 1;
            while( bit < _n )
            {
                bit *= 2;
                _d++;
            }
            nodes = new SNode[bit * 2];
            rep(i, bit * 2) nodes[i]._last = false;
        }

        ~SegTree()
        {
            delete nodes;
        }

        void set(int i, int value)
        {
            int index = dindex(_d - 1) + i;
            nodes[index].set(value);
            nodes[index]._min = i - value;
            evalnode(index / 2);
        }

        int get(int i)
        {
            return getsub(i, 1, 0);
        }

        void setrange(int l, int r, int value)
        {
            setrangesub(l, r, 1, 0, value);
        }

        // l <= i < r
        int getmin(int l, int r)
        {
            return getminsub(l, r, 1, 0);
        }
};


int main()
{
    int h, w; cin >> h >> w;
    SegTree st(w);
    rep(i, w) st.set(i, i);
    rep(i, h)
    {
        int a, b; cin >> a >> b; a--; b--;
        int r = -w * 2;
        if( a > 0 ) r = st.get(a - 1);
        st.setrange(a, b + 1, r);
#if 0        
        cout << i << ":" << endl;
        rep(j, w) cout << st.get(j) << " ";
        cout << endl;
        rep(j, w) cout << st.getmin(j, j + 1) << " ";
        cout << endl;
#endif
        int ret = st.getmin(0, w);
        if( ret > w )
        {
            cout << -1 << endl;
        }
        else
        {
            cout << ret + i + 1 << endl;
        }
    }
    return 0;    
}

Measured memory_bytes: 9272