#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <optional>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

struct intvl
{
    int l;
    int r;
};

#ifdef DEBUG
ostream &operator<<(ostream &os, intvl lr)
{
    os << '[' << lr.l << ',' << lr.r << ')';
    return os;
}
#endif

template <typename M>
struct seg_tree
{
    int n;
    using T = typename M::T;
    using T_act = typename M::T_act;

private:
    vector<T> data;
    vector<T_act> data_act;

    // ノードから区間への対応
    vector<intvl> intvl_s;

    // ノードの端点を得る
    intvl const &intvl_of_node(int const i)
    {
        return intvl_s[i];
    }

    // (2ベキでないときに出てくる)不要なノードならfalse
    bool is_valid_node(int const i)
    {
        intvl lr = intvl_of_node(i);
        return lr.l < lr.r;
    }

    // ノードiの値
    T get(int const i)
    {
        intvl lr = intvl_of_node(i);
        return M::act(data[i], data_act[i], lr);
    }

    // ノードiの親すべてから伝播
    void propagate(int const i)
    {
        for (int e = 31 - __builtin_clz(i); e >= 1; e--)
        {
            int pa = i >> e;
            if (not is_valid_node(pa))
            {
                continue;
            }

            assert(data[pa] == M::op(get(2 * pa), get(2 * pa + 1)));

            for (int ch = 2 * pa; ch <= 2 * pa + 1; ch++)
            {
                data_act[ch] = M::op_act(data_act[ch], data_act[pa]);
            }
            data[pa] = get(pa);
            data_act[pa] = M::id_act;

            assert(data[pa] == M::op(get(2 * pa), get(2 * pa + 1)));
        }
    }

    // ノードiの親すべてに変更を反映
    void reflect_change(int i)
    {
        while (i > 1)
        {
            i /= 2;
            if (not is_valid_node(i))
            {
                break;
            }
            data[i] = M::op(get(2 * i), get(2 * i + 1));
        }
    }

    // ノードから区間の端点への対応を前計算
    void init_intvl_s()
    {
        for (int i = 0; i < n; i++)
        {
            intvl_s[n + i] = {i, i + 1};
        }
        for (int i = n - 1; i >= 1; i--)
        {
            intvl_s[i] = {intvl_s[2 * i].l, intvl_s[2 * i + 1].r};
        }
    }

public:
    // idで初期化
    explicit seg_tree(int const size)
        : n(size), data(2 * size, M::id), data_act(2 * size, M::id_act), intvl_s(2 * size)
    {
        init_intvl_s();
    }

    // a_sで初期化
    seg_tree(int const size, vector<T> const &a_s)
        : n(size), data(2 * size), data_act(2 * size, M::id_act), intvl_s(2 * size)
    {
        init_intvl_s();

        for (int i = 0; i < n; i++)
        {
            data[n + i] = a_s[i];
        }
        for (int i = n - 1; i >= 1; i--)
        {
            if (not is_valid_node(i))
            {
                continue;
            }
            data[i] = M::op(data[2 * i], data[2 * i + 1]);
        }
    }

    void act(T_act const &u, intvl const &lr)
    {
        assert(0 <= lr.l && lr.l < lr.r && lr.r <= n);

        propagate(lr.l + n);
        propagate(lr.r - 1 + n);

        int l = lr.l + n, r = lr.r + n;
        while (l < r)
        {
            if (l & 1)
            {
                data_act[l] = M::op_act(data_act[l], u);
                l++;
            }
            if (r & 1)
            {
                r--;
                data_act[r] = M::op_act(data_act[r], u);
            }
            l /= 2;
            r /= 2;
        }

        reflect_change(lr.l + n);
        reflect_change(lr.r - 1 + n);
    }

    // 区間和を返す
    T query(intvl const &lr)
    {
        assert(0 <= lr.l && lr.l < lr.r && lr.r <= n);

        propagate(lr.l + n);
        propagate(lr.r - 1 + n);

        int l = lr.l + n, r = lr.r + n;
        T ret_l = M::id, ret_r = M::id;
        while (l < r)
        {
            if (l & 1)
            {
                ret_l = M::op(ret_l, get(l));
                l++;
            }
            if (r & 1)
            {
                r--;
                ret_r = M::op(get(r), ret_r);
            }
            l /= 2;
            r /= 2;
        }

        return M::op(ret_l, ret_r);
    }
};

struct mon
{
    using T = int;
    using T_act = optional<int>;

    static T op(T a, T b)
    {
        return min(a, b);
    }
    static constexpr inline T id = 2'00'001;

    static T_act op_act(T_act const &u, T_act const &v)
    {
        if (not v)
        {
            return u;
        }
        return v;
    }
    static constexpr inline T_act id_act = nullopt;

    static T act(T const a, T_act const &u, intvl const &lr)
    {
        if (not u)
        {
            return a;
        }
        return u.value() + lr.l;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

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

    vector init(w + 1, 0);
    init[0] = mon::id;
    seg_tree<mon> seg(w + 1, init);

    rep(y, h)
    {
        int l, r;
        cin >> l >> r;
        --l;
        auto s = seg.query({l, l + 1});
        seg.act(make_optional(s - l), {l + 1, r + 1});
        auto res = seg.query({0, w + 1});
        if (res >= mon::id)
        {
            res = -1;
        }
        else
        {
            res += y + 1;
        }
        cout << res << '\n';
    }

    return 0;
}


Measured memory_bytes: 11868