#include <iostream>
#include <iomanip>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,a) for(ll i=ll(a-1);i>=0;--i)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}

const ll INF = 1e9;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ll EPS = 1e-10;
int sgn(const double a){
    return (a < -EPS ? -1 : (a > EPS ? +1 : 0));
}
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
typedef complex<double> Point;
const ll MAX = 201;
constexpr ll nx[4] = {-1,0,1,0};
constexpr ll ny[4] = {0,1,0,-1};
class LazySegTree{
    private:
        ll n;
        vector<ll> node,lazy;
    public:
        LazySegTree(vector<ll> v){
            ll sz = v.size();
            n = 1;
            while(n < sz) n *= 2;
            node.resize(2*n-1);
            lazy.resize(2*n-1,0);
            rep(i,sz) node[i+n-1] = v[i];
            for (int i = n-2;i >= 0;i--) node[i] = min(node[i*2+1],node[i*2+2]);
        }
        void eval(ll k,ll l,ll r){
            if (lazy[k] != 0){
                node[k] += lazy[k];
                if (r-l > 1){
                    lazy[2*k+1] += lazy[k];
                    lazy[2*k+2] += lazy[k];
                }
                lazy[k] = 0;
            }
        }
        void add(ll a,ll b,ll x,ll k=0,ll l=0,ll r=-1){
            if (r < 0) r = n;
            eval(k,l,r);
            if (b <= l || r <= a) return;
            if (a <= l && r <= b){
                lazy[k] += x;
                eval(k,l,r);
            }
            else{
                add(a,b,x,2*k+1,l,(l+r)/2);
                add(a,b,x,2*k+2,(l+r)/2,r);
                node[k] = min(node[2*k+1],node[2*k+2]);
            }
        }
        ll query(ll a,ll b,ll k = 0,ll l = 0,ll r = -1){
            if (r < 0) r = n;
            eval(k,l,r);
            if (b <= l || r <= a) return INF*INF;
            if (a <= l && r <= b) return node[k];
            ll vl = query(a,b,2*k+1,l,(l+r)/2);
            ll vr = query(a,b,2*k+2,(l+r)/2,r);
            return min(vl,vr);
        }
        void show(){
            array_output(node.begin()+n-1,node.end());
        }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h,w;
    cin >> h >> w;
    LazySegTree v(vector<ll>(w,0));
    rep(i,h){
        ll a,b;
        cin >> a >> b;
        a--,b--;
        ll l = a,r = b+1;
        while (r-l > 1){
            ll m = (l+r)/2;
            if (v.query(m,b+1) >= INF) r = m;
            else l = m;
        }
        if (b < w-1){
            ll o = v.query(b+1,b+2),n = v.query(l,l+1)+b+1-l;
            if (n < o){
                v.add(b+1,b+2,n-o);
            }
        }
        v.add(0,w,1);
        v.add(a,b+1,INF);
        ll ans = v.query(0,w);
        if (ans >= INF) PRINT(-1);
        else PRINT(ans);
    }
}


Measured memory_bytes: 12956