#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#ifdef _LOCAL_DEBUG
#define en_if typename enable_if<sizeof x<T>(0) == 4, ostream&>::type
namespace dbg {
template<class T> char x(...); 
template<class T> auto x(T* v) -> decltype(v->size(), 0); 
template<class T> auto x(T* v) -> decltype(v->c_str(), "");
template<class T> en_if operator<<(ostream& os, const T& v) { 
    os << "["; const char* sep = ""; 
    for(const auto& x : v) os << sep << x, sep = ", ";
    return os << "]";
}
template<class F, class S> 
ostream& operator<<(ostream& os, const pair<F, S>& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template<class T> 
void print(const char* n, T e) { cerr << "[" << n << ": " << e << "]\n"; }
template<class Head, class... Tail> 
void print(const char* n, Head h, Tail... t) {
    cerr << "["; while(*n != ',') cerr << *n++; cerr << ": " << h << "] ";
    print(n + 2, t...); 
}}
#define debug(...) dbg::print(#__VA_ARGS__, __VA_ARGS__);
#else
#define debug(...)
#endif

constexpr int INF = 1e9 + 5;

struct segTree {
    int B = 1;
    vector<int> tag;
    vector<int> t;
    segTree(int n) {
        while (B < n) B *= 2;
        tag.resize(2 * B, 0);
        t.resize(2 * B);
    }
    void pull(int u) {
        t[u] = min(t[u * 2 + 1], t[u * 2 + 2]);
    }
    void push(int u, int L, int R) {
        if (tag[u] == 0) return;
        int M = (L + R) / 2, lc = u * 2 + 1, rc = u * 2 + 2;
        t[lc] =  tag[u];
        t[rc] = tag[u] + (M - L);
        tag[lc] = tag[u];
        tag[rc] = tag[u] + (M - L);
        tag[u] = 0;
    }
    void update(int u, int L, int R, int ql, int qr, int v) {
        debug(u, L, R, ql, qr, v);
        if (R <= ql || qr <= L)
            return;
        if (ql <= L && R <= qr) {
            t[u] =  v;
            tag[u] = v;
            return;
        }
        push(u, L, R);
        int M = (L + R) / 2, lc = u * 2 + 1, rc = u * 2 + 2;
        update(lc, L, M, ql, qr, v);
        update(rc, M, R, ql, qr, v + max(0, (M - max(L, ql))));
        pull(u);
    }
    void update(int l, int r, int v) {
        update(0, 0, B, l, r, v);
    }
    int query(int u, int L, int R, int ql, int qr) {
        if (R <= ql || qr <= L)
            return INF;
        if (ql <= L && R <= qr)
            return t[u];
        push(u, L, R);
        int M = (L + R) / 2, lc = u * 2 + 1, rc = u * 2 + 2;
        int ret = min(query(lc, L, M, ql, qr), query(rc, M, R, ql, qr));
        // debug(L, R, ql, qr, ret);
        return ret;
    }
    int query(int l, int r) {
        if (l >= r) return INF;
        return query(0, 0, B, l, r);
    }
};


int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    bool dead = false;
    int l, r, ans = 0;
    segTree st(m);
    for (int z = 1; z <= n; z++) {
        cin >> l >> r;
        l--, r--;
        if (dead) {
            cout << "-1\n";
            continue;
        }
        int vl = l == 0 ? INF : st.query(l - 1, l);
        st.update(l, r + 1, vl + 1);
        ans = st.query(0, m);
        if (ans >= INF) {
            cout << "-1\n";
            dead = true;
        } else {
            cout << ans + z << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 7444