#include<bits/stdc++.h>

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int h,w;
    cin>>h>>w;
    map<int,int> m;
    multiset<int> s;
    for(int i=0;i<w;++i)m[i]=i,s.insert(0);
    for(int i=0;i<h;++i){
        int a,b;
        cin>>a>>b;
        a--;
        auto it = m.lower_bound(a);
        int ma = -1;
        while(it != m.end() and it->first <= b){
            ma = max(ma,it->second);
            s.erase(s.find(it->first - it->second));
            m.erase(it++);
        }
        if(ma != -1 and b < w){s.insert(b-ma);m[b] = ma;}
        
        int ret =-1;
        if(s.size() > 0)ret = *s.begin() + (i+1);
        cout << ret << endl;
    }
    return 0;
    
}
