#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

template <class T, class E>
struct LazySegTree {
    using F = function<T(T, T)>;
    using G = function<T(T, E)>;
    using H = function<E(E, E)>;
    using P = function<E(E, int)>;
    int sz = 1, seq_sz;
    F f;
    G g;
    H h;
    T et;
    E ee;
    P p;
    int cur = 0;
    vector<T> node;
    vector<E> lazy;
    vector<int> idx, len;

    LazySegTree(
        int sz_, T et_, E ee_, F f_, G g_, H h_,
        P p_ = [](E a, int b) { return a; })
        : seq_sz(sz_), et(et_), ee(ee_), f(f_), g(g_), h(h_), p(p_) {
        while (sz < sz_) sz <<= 1;
        node.resize(sz << 1, et);
        lazy.resize(sz << 1, ee);
        idx.resize(sz, -1);
        len.resize(sz << 1, 0);
        For(i, sz, sz << 1) len[i] = 1;
        rFor(i, sz, 1) len[i] = len[i << 1] + len[(i << 1) + 1];
    }

    void build(vector<T> &a) {
        rep(i, a.size()) node[i + sz] = a[i];
        rFor(i, sz, 1) node[i] = f(node[i << 1], node[(i << 1) + 1]);
    }

    void build(T x) {
        rep(i, seq_sz) node[i + sz] = x;
        rFor(i, sz, 1) node[i] = f(node[i << 1], node[(i << 1) + 1]);
    }

    inline void push(int i) {
        if (lazy[i] == ee) return;
        if (i < sz) {
            lazy[i << 1] = h(lazy[i << 1], lazy[i]);
            node[i << 1] = g(node[i << 1], p(lazy[i], len[i << 1]));
            lazy[(i << 1) + 1] = h(lazy[(i << 1) + 1], lazy[i]);
            node[(i << 1) + 1] =
                g(node[(i << 1) + 1], p(lazy[i], len[(i << 1) + 1]));
        }
        lazy[i] = ee;
    }

    inline void prop(int l, int r) {
        cur = 0;
        if (l == sz && r == sz << 1) return;
        l = (l / (l & -l)) >> 1;
        r = (r / (r & -r)) >> 1;
        while (l > 1 || r > 1) {
            if (l >= r) {
                idx[cur++] = l;
                l >>= 1;
            } else {
                idx[cur++] = r;
                r >>= 1;
            }
        }
        idx[cur++] = 1;

        rrep(k, cur) push(idx[k]);
    }

    void update(int l, int r, E x) {
        l += sz;
        r += sz;
        prop(l, r);
        for (; l < r; l >>= 1, r >>= 1) {
            if (l & 1) {
                lazy[l] = h(lazy[l], x);
                node[l] = g(node[l], p(x, len[l]));
                ++l;
            }
            if (r & 1) {
                --r;
                lazy[r] = h(lazy[r], x);
                node[r] = g(node[r], p(x, len[r]));
            }
        }
        rep(k, cur) {
            int i = idx[k];
            if (i < sz) node[i] = f(node[i << 1], node[(i << 1) + 1]);
        }
    }

    T query(int l, int r) {
        l += sz;
        r += sz;
        prop(l, r);
        T vl = et, vr = et;
        for (; l < r; l >>= 1, r >>= 1) {
            if (l & 1) vl = f(vl, node[l++]);
            if (r & 1) vr = f(node[--r], vr);
        }
        return f(vl, vr);
    }
};

int main() {
    int h, w;
    scanf("%d%d", &h, &w);
    int a[h], b[h];
    rep(i, h) {
        scanf("%d%d", &a[i], &b[i]);
        --a[i];
    }
    auto f = [](int x, int y) { return min(x, y); };
    auto g = [](int x, int y) { return y; };
    LazySegTree<int, int> st(w, MAX, -1, f, g, g);
    vector<int> v(w);
    rep(i, w) v[i] = i;
    st.build(v);
    set<pii> S, T;  // S: (pos, diff), T: (diff, pos)
    rep(i, w) {
        S.emplace(i, 0);
        T.emplace(0, i);
    }
    rep(i, h) {
        for (auto itr = S.lower_bound({a[i], -1});
             itr != S.end() && itr->first < b[i];) {
            T.erase({itr->se, itr->fi});
            itr = S.erase(itr);
        }
        if (b[i] < w) {
            auto tmp = st.query(b[i], b[i] + 1);
            if (tmp < MAX) {
                S.emplace(b[i], b[i] - tmp);
                T.emplace(b[i] - tmp, b[i]);
            }
        }
        st.update(a[i], b[i], MAX);
        if (a[i] > 0) {
            st.update(a[i], b[i], st.query(a[i] - 1, a[i]));
        }
        printf("%d\n", T.empty() ? -1 : T.begin()->fi + i + 1);
    }
}

Measured memory_bytes: 31416