#include <bits/extc++.h>
using namespace std;
using i64=int64_t;

struct union_find
{
    union_find(const size_t n = 0) : link(n, -1) {}

    size_t find(size_t x)
    {
        assert(x < size());
        return link[x] < 0 ? x : (link[x] = find(link[x]));
    }

    size_t size() const { return link.size(); }

    size_t size(const size_t x)
    {
        assert(x < size());
        return -link[find(x)];
    }

    bool same(const size_t x, const size_t y)
    {
        assert(x < size() && y < size());
        return find(x) == find(y);
    }

    bool unite(size_t x, size_t y)
    {
        assert(x < size() && y < size());
        x = find(x), y = find(y);
        if(x == y) return false;
        if(link[x] > link[y]) std::swap(x, y);
        link[x] += link[y];
        link[y] = x;
        return true;
    }

protected:
    std::vector<int> link;
}; // class union_find


template <class monoid, class endomorphism>
class lazy_segment_tree
{
    using size_type = typename std::vector<monoid>::size_type;
    template <class T> using container_type = std::vector<T>;

    size_type size_orig, height, size_ext;
    container_type<monoid> data;
    container_type<endomorphism> lazy;

    void recalc(const size_type node) { data[node] = data[node << 1] + data[node << 1 | 1]; }

    void apply(size_type index, const endomorphism &endo)
    {
        endo.apply(data[index]);
        if(index < size_ext) lazy[index] *= endo;
    }

    void push(size_type index)
    {
        if(index >= size_ext) return;
        apply(index << 1, lazy[index]);
        apply(index << 1 | 1, lazy[index]);
        lazy[index] = endomorphism{};
    }

    template <class pred_type>
    size_type left_search_subtree(size_type index, const pred_type pred, monoid mono)
    {
        assert(index);
        while(index < size_ext)
        {
            push(index);
            const monoid tmp = data[(index <<= 1) | 1] + mono;
            if(pred(tmp)) mono = tmp;
            else ++index;
        }
        return ++index -= size_ext;
    }

    template <class pred_type>
    size_type right_search_subtree(size_type index, const pred_type pred, monoid mono)
    {
        assert(index);
        while(index < size_ext)
        {
            push(index);
            const monoid tmp = mono + data[index <<= 1];
            if(pred(tmp)) ++index, mono = tmp;
        }
        return (index -= size_ext) < size_orig ? index : size_orig;
    }

public:
    lazy_segment_tree(const size_type n = 0) : size_orig{n}, height(n > 1 ? 32 - __builtin_clz(n - 1) : 0), size_ext{1u << height}, data(size_ext << 1), lazy(size_ext) {}

    lazy_segment_tree(const size_type n, const monoid &init) : lazy_segment_tree(n)
    {
        std::fill(std::next(std::begin(data), size_ext), std::end(data), init);
        for(size_type i{size_ext}; --i; ) recalc(i);
    }

    template <class iter_type, class value_type = typename std::iterator_traits<iter_type>::value_type>
    lazy_segment_tree(iter_type first, iter_type last)
        : size_orig(std::distance(first, last)), height(size_orig > 1 ? 32 - __builtin_clz(size_orig - 1) : 0), size_ext{1u << height}, data(size_ext << 1), lazy(size_ext)
    {
        static_assert(std::is_constructible<monoid, value_type>::value, "monoid(iter_type::value_type) is not constructible.");
        for(auto iter{std::next(std::begin(data), size_ext)}; iter != std::end(data) && first != last; ++iter, ++first) *iter = monoid(*first);
        for(size_type i{size_ext}; --i; ) recalc(i);
    }

    template <class container_type, typename = typename container_type::value_type>
    lazy_segment_tree(const container_type &cont) : lazy_segment_tree(std::begin(cont), std::end(cont)) {}

    size_type size() const { return size_orig; }
    size_type capacity() const { return size_ext; }

    monoid operator[](size_type index) { return fold(index, index + 1); }

    void update(const size_type index, const endomorphism &endo) { update(index, index + 1, endo); }

    void update(size_type first, size_type last, const endomorphism &endo)
    {
        assert(last <= size_orig);
        if(first >= last) return;
        first += size_ext, last += size_ext - 1;
        for(size_type i = height; i; --i) push(first >> i), push(last >> i);
        for(size_type l = first, r = last + 1; last; l >>= 1, r >>= 1)
        {
            if(l < r)
            {
                if(l & 1) apply(l++, endo);
                if(r & 1) apply(--r, endo);
            }
            if(first >>= 1, last >>= 1)
            {
                recalc(first), recalc(last);
            }
        }
    }

    monoid fold() { return fold(0, size_orig); }

    monoid fold(size_type first, size_type last)
    {
        assert(last <= size_orig);
        if(first >= last) return monoid{};
        first += size_ext, last += size_ext - 1;
        monoid left_val{}, right_val{};
        for(size_type l = first, r = last + 1; last; l >>= 1, r >>= 1)
        {
            if(l < r)
            {
                if(l & 1) left_val = left_val + data[l++];
                if(r & 1) right_val = data[--r] + right_val;
            }
            if(first >>= 1, last >>= 1)
            {
                lazy[first].apply(left_val);
                lazy[last].apply(right_val);
            }
        }
        return left_val + right_val;
    }

    template <class pred_type>
    size_type left_search(size_type right, const pred_type pred)
    {
        assert(right <= size_orig);
        right += size_ext - 1;
        for(size_type i{height}; i; --i) push(right >> i);
        ++right;
        monoid mono{};
        for(size_type left{size_ext}; left != right; left >>= 1, right >>= 1)
        {
            if((left & 1) != (right & 1))
            {
                const monoid tmp = data[--right] + mono;
                if(!pred(tmp)) return left_search_subtree(right, pred, mono);
                mono = tmp;
            }
        }
        return 0;
    }

    template <class pred_type>
    size_type right_search(size_type left, const pred_type pred)
    {
        assert(left <= size_orig);
        left += size_ext;
        for(size_type i{height}; i; --i) push(left >> i);
        monoid mono{};
        for(size_type right{size_ext << 1}; left != right; left >>= 1, right >>= 1)
        {
            if((left & 1) != (right & 1))
            {
                const monoid tmp = mono + data[left];
                if(!pred(tmp)) return right_search_subtree(left, pred, mono);
                mono = tmp;
                ++left;
            }
        }
        return size_orig;
    }
}; //class lazy_segment_tree

const i64 inf=1e18;

template <class T>
struct min_monoid
{
    using value_type = T;
    T value;
    static T &max()
    {
        static T max = std::numeric_limits<T>::max();
        return max;
    }
    min_monoid() : value(max()) {}
    min_monoid(const T &val) : value(val) {}
    operator T() const { return value; }
    min_monoid operator+(const min_monoid& rhs) const
    {
        return value < rhs.value ? *this : rhs;
    }
};

template <class T>
struct max_monoid
{
    using value_type = T;
    T value;
    max_monoid() : value(std::numeric_limits<T>::min()) {}
    max_monoid(const T &val) : value(val) {}
    operator T() const { return value; }
    max_monoid operator+(const max_monoid& rhs) const
    {
        return value > rhs.value ? *this : rhs;
    }
};

struct endo
{
    i64 val;
    bool ch=0;

    endo operator*=(const endo& rhs)
    {
        if(rhs.ch)
        {
            *this=rhs;
        }
        return *this;
    }

    template <class M>
    void apply(M& x) const
    {
        if(ch) x=val;
    }
};


main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    using mono=min_monoid<i64>;
    using mono2=max_monoid<i64>;

    int h,w; cin>>h>>w;

    lazy_segment_tree<mono,endo> seg;
    {
        vector<mono> init(w+1);
        for(int i=0; i<w; ++i)
        {
            init[i]=0;
        }
        seg=init;
    }
    lazy_segment_tree<mono2,endo> seg2;
    {
        vector<mono2> init(1+w);
        for(int i=0; i<=w; ++i)
        {
            init[i]={i};
        }
        seg2=init;
    }
    for(int a=0,b=0,i=1; i<=h; i++)
    {
        cin>>a>>b; a--;
        i64 k=seg2.fold(a,b).value;
        if(seg2[b].value<k)
        {
            seg2.update(b,{k,1});
            seg.update(b,{b-k,1});
        }
        seg2.update(a,b,{-inf,1});
        seg.update(a,b,{inf,1});
        i64 ans=seg.fold().value+i;
        if(ans<inf) cout<<ans<<"\n";
        else cout<<"-1\n";
    }
}


Measured memory_bytes: 21340