#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:
    IFD(public:)
    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)
    {
        debug(i);
        for (int e = 31 - __builtin_clz(i); e >= 1; e--)
        {
            int pa = i >> e;
            if (not is_valid_node(pa))
            {
                continue;
            }

            debug(pa);
            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 inline vector<T> vec;

    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 u, T_act v)
    {
        if (not v)
        {
            return u;
        }
        return v;
    }
    static constexpr inline T_act id_act = nullopt;

    static T act(T a, T_act u, intvl 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);

    // debug(mon::op_act(make_optional(5), mon::id_act));
    // debug(mon::op_act(mon::id_act, make_optional(5)));
    // debug(mon::op_act(make_optional(10), make_optional(2)));

    int h, w;
    cin >> h >> w;
    // 0-based, [a,b)
    vector ab_s(h, pair<int, int>());
    rep(y, h)
    {
        int a, b;
        cin >> a >> b;
        --a;
        ab_s[y] = {a, b};
    }

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

    debug(seg.intvl_s);

    rep(y, h)
    {
        auto &[l, r] = ab_s[y];
        debug(l, r);
        debug(seg.data);
        debug(seg.data_act);
        auto s = seg.query({l, l + 1});
        debug(seg.data);
        debug(seg.data_act);
        seg.act(make_optional(s - l), {l + 1, r + 1});
        // seg.query({0, w + 1});
        // IFD(rep(x, w + 1) { debug(x, seg.query({x, x + 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: 13472