#include <bits/stdc++.h>
#define FASTIO
using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

template <typename T1, typename T2>
bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

template <class T, class E, class F, class G, class H, class P>
class LazySegmentTree {
private:
    const F f;
    const G g;
    const H h;
    const P p;
    const T tid;
    const E eid;
    std::vector<T> vec;
    std::vector<E> lazy;
    int sz;

public:
    explicit LazySegmentTree(
        int n, F f, G g, H h, P p, T tid, E eid) noexcept
        : f(f), g(g), h(h), p(p), tid(tid), eid(eid) {
        sz = 1;
        while (sz < n) sz <<= 1;
        vec.assign(sz * 2 - 1, tid);
        lazy.assign(sz * 2 - 1, eid);
    }
    T& operator[](int idx) noexcept {
        return vec[sz - 1 + idx];
    }
    void set_value(int idx, T val) noexcept {
        vec[sz - 1 + idx] = val;
    }
    void build() noexcept {
        for (int i = sz - 2; i >= 0; i--) {
            vec[i] = f(vec[i * 2 + 1], vec[i * 2 + 2]);
        }
    }
    void eval(int k, int l, int r) noexcept {
        if (lazy[k] == eid) return;
        if (r - l > 1) {
            lazy[k * 2 + 1] = h(lazy[k * 2 + 1], lazy[k]);
            lazy[k * 2 + 2] = h(lazy[k * 2 + 2], lazy[k]);
        }
        vec[k] = g(vec[k], p(lazy[k], r - l));
        lazy[k] = eid;
    }
    void update(int a, int b, E x) noexcept {
        _update(a, b, x, 0, 0, sz);
    }
    T query(int a, int b) noexcept {
        return _query(a, b, 0, 0, sz);
    }

private:
    T _update(int a, int b, E x, int k, int l, int r) noexcept {
        eval(k, l, r);
        if (b <= l || r <= a) return vec[k];
        if (a <= l && r <= b) {
            lazy[k] = h(lazy[k], x);
            return g(vec[k], p(lazy[k], r - l));
        }
        else {
            T t1 = _update(a, b, x, k * 2 + 1, l, (l + r) >> 1);
            T t2 = _update(a, b, x, k * 2 + 2, (l + r) >> 1, r);
            return vec[k] = f(t1, t2);
        }
    }
    T _query(int a, int b, int k, int l, int r) noexcept {
        if (b <= l || r <= a) return tid;
        eval(k, l, r);
        if (a <= l && r <= b) {
            return vec[k];
        }
        else {
            T t1 = _query(a, b, k * 2 + 1, l, (l + r) >> 1);
            T t2 = _query(a, b, k * 2 + 2, (l + r) >> 1, r);
            return f(t1, t2);
        }
    }
};

void solve() {
    ll H, W;
    cin >> H >> W;
    vector<Pii> walls(H);
    for (ll i = 0; i < H; i++) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        walls[i] = {a, b};
    }

    ll tid = L_INF;
    ll eid = -1;
    auto opf = [](ll a, ll b) -> ll { return min(a, b); };
    auto opg = [&](ll a, ll b) -> ll { return b == eid ? a : b; };
    auto oph = [&](ll a, ll b) -> ll { return b == eid ? a : b; };
    auto opp = [](ll a, ll k) -> ll { return a; };
    LazySegmentTree seg1(W, opf, opg, oph, opp, tid, eid);
    LazySegmentTree seg2(W, opf, opg, oph, opp, tid, eid);
    for (ll i = 0; i < W; i++) {
        seg1[i] = 0;
        seg2[i] = W - 1 - i;
    }
    seg1.build();
    seg2.build();

    for (ll i = 0; i < H; i++) {
        auto [left, right] = walls[i];
        if (right + 1 < W) {
            ll q = seg2.query(left, right + 2);
            if (q != tid) {
                q -= W - 1 - (right + 1);
                seg1.update(right + 1, right + 2, q);
                seg2.update(right + 1, right + 2, q + W - 1 - (right + 1));
            }
        }
        seg1.update(left, right + 1, tid);
        seg2.update(left, right + 1, tid);
        ll res = seg1.query(0, W);
        if (res == tid) {
            prints()(-1);
        }
        else {
            prints()(res + i + 1);
        }

        // for (ll i = 0; i < W; i++) {
        //     prints("", " ")(seg1.query(i, i + 1));
        // }
        // prints()();
        // for (ll i = 0; i < W; i++) {
        //     prints("", " ")(seg2.query(i, i + 1));
        // }
        // prints()();
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(nullptr), cout.tie(nullptr);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 21132