#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;

// input
int H, W;
vector<int> A, B;

set<P> s;
multiset<int> w;


void input() {
    cin >> H >> W;
    A = B = vector<int>(H);
    rep(i, H) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
    }
}


int main() {
    input();
    rep(i, W) {
        s.insert(P(i, i));
        w.insert(0);
    }
    rep(i, H) {
        auto x = s.lower_bound(P(A[i], 0));
        auto y = s.lower_bound(P(B[i] + 1, 0));
        if (x != s.end() && y != s.begin() && x != y) {
            y--;
            while (x != y) {
                int v = x->first - x->second;
                w.erase(w.find(v));
                s.erase(x++);
            }
            if (B[i] < W - 1) {
                s.insert(P(B[i] + 1, x->second));
                w.insert(B[i] + 1 - x->second);
            }
            int v = x->first - x->second;
            w.erase(w.find(v));
            s.erase(x);
        }
        ll ans;
        if (w.empty()) ans = -1;
        else ans = ll(i) + 1 + (*w.begin());
        cout << ans << endl;
    }
}
