#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

struct LazySegTree {
    int siz;
    vector<pii> node;
    vector<int> lazy;
    vector<int> ridx;
    vector<int> minode;

    LazySegTree(int N) : siz(1) {
        while (siz < N)
            siz *= 2;

        ridx.resize(2 * siz - 1, -1);
        node.resize(2 * siz - 1);
        minode.resize(2 * siz - 1);
        for (int i = 0; i < siz; ++i) {
            ridx[i + siz - 1] = i;
            node[i + siz - 1] = {i, i};
            minode[i + siz - 1] = i;
        }
        for (int i = siz - 2; i >= 0; --i) {
            ridx[i] = max(ridx[2 * i + 1], ridx[2 * i + 2]);
            node[i] = node[2 * i + 1];
            minode[i] = min(minode[2 * i + 1], minode[2 * i + 2]);
        }

        lazy.resize(2 * siz - 1, -1);
    }

    int calc(pii &nd) {
        return nd.first - nd.second;
    }

    void eval(int k) {
        if (lazy[k] < 0)
            return;
        if (k < siz - 1) {
            lazy[2 * k + 1] = lazy[k];
            lazy[2 * k + 2] = lazy[k];
        }

        node[k] = {lazy[k], ridx[k]};
        minode[k] = lazy[k];
        lazy[k] = -1;
    }

    void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        eval(k);
        if (r <= a || b <= l)
            return;
        if (a <= l && r <= b) {
            lazy[k] = x;
            eval(k);
            return;
        }
        update(a, b, x, 2 * k + 1, l, (l + r) / 2);
        update(a, b, x, 2 * k + 2, (l + r) / 2, r);
        minode[k] = min(minode[2 * k + 1], minode[2 * k + 2]);
        if (calc(node[2 * k + 1]) <= calc(node[2 * k + 2]))
            node[k] = node[2 * k + 1];
        else
            node[k] = node[2 * k + 2];
    }

    pii query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        eval(k);
        if (r <= a || b <= l)
            return {INT_MAX, 0};
        if (a <= l && r <= b)
            return node[k];
        pii vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        pii vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        if (calc(vl) <= calc(vr))
            return vl;
        else
            return vr;
    }

    int lb(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
        if (r < 0)
            r = siz;

        eval(k);
        if (minode[k] >= x || r <= a || b <= l)
            return a - 1;
        if (k >= siz - 1)
            return k - siz + 1;
        int vr = lb(a, b, x, 2 * k + 2, (l + r) / 2, r);
        if (vr != a - 1)
            return vr;
        return lb(a, b, x, 2 * k + 1, l, (l + r) / 2);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W;
    cin >> H >> W;
    LazySegTree segt(W);
    bool isng = false;
    for (int i = 0; i < H; ++i) {
        int A, B;
        cin >> A >> B;
        A--;

        if (isng) {
            cout << -1 << '\n';
            continue;
        }

        int l = segt.lb(0, W, A) + 1;
        int r = segt.lb(0, W, B) + 1;

        if (B < W)
            segt.update(l, r, B);
        else
            segt.update(l, r, INT_MAX);

        pii p = segt.query(0, W);
        int res = p.first - p.second;
        if (res >= 1e9) {
            cout << -1 << '\n';
            isng = true;
        } else
            cout << res + i + 1 << '\n';
    }

    return 0;
}


Measured memory_bytes: 13468