#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int INF = 1e8;

struct SqrtDecomposition{
    int n, sqrtn, k;
    VI dat, buk, lazy;
    vector<bool> lazyflag;

    void init(int x){
        n = x;
        sqrtn = sqrt(n);
        k = (n + sqrtn - 1) / sqrtn;
        dat.assign(sqrtn * k, -INF);
        REP(i,n) dat[i] = i;
        buk.assign(k, 0);
        lazy.assign(k, 0);
        lazyflag.assign(k, false);
    }

    void eval(int b){
        if (!lazyflag[b]) return;
        lazyflag[b] = false;
        FOR(i, sqrtn * b, sqrtn * (b+1) - 1){
            dat[i] = lazy[b];
        }
    }

    // [l, r)
    void update(int l, int r, int x){
        REP(b,k){
            int p = sqrtn * b;
            int q = sqrtn * (b+1);
            if (q <= l || r <= p) continue;
            if (l <= p && q <= r){
                buk[b] = p - x;
                lazyflag[b] = true;
                lazy[b] = x;
            }else{
                eval(b);
                FOR(i,max(l,p),min(r,q)-1){
                    dat[i] = x;
                }
                buk[b] = INF;
                FOR(i,p,q-1){
                    chmin(buk[b], i - dat[i]);
                }
            }
        }
    }

    // [l, r)
    int query(int l, int r){
        int ret = INF;
        REP(b,k){
            int p = sqrtn * b;
            int q = sqrtn * (b+1);
            if (q <= l || r <= p) continue;
            if (l <= p && q <= r){
                ret = min(ret, buk[b]);
            }else{
                eval(b);
                FOR(i,max(l,p),min(r,q)-1){
                    ret = min(ret, i - dat[i]);
                }
            }
        }
        return ret;
    }
};


int main(void){
    int h, w;
    cin >> h >> w;
    SqrtDecomposition sd;
    sd.init(w);
    REP(i,h){
        int l = in() - 1, r = in(), u = -INF;
        if (l > 0){
            int b = (l - 1) / sd.sqrtn;
            sd.eval(b);
            u = sd.dat[l - 1];
        }
        sd.update(l, r, u);
        int ans = sd.query(0, w);
        if (ans >= INF) ans = -1;
        else ans += i + 1;
        // REP(i,w) cout << sd.dat[i] << " ";
        // cout << endl;
        // REP(i,w) cout << sd.query(i, i + 1) << " ";
        // cout << endl;
        // REP(i,2) cout << sd.buk[i] << " ";
        // cout << endl;
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 4076