#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>

 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;



long long gcd(long long a, long long b) { 
    if (a == 0)  {   return b;  }
    return gcd(b % a, a); 
};


int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, modd);   // rand_gen(rng) gets the rand no

//    auto start = chrono::steady_clock::now()

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(h); readint(w);
        vector<pair<int,int>> ints;
        forr(i,0,h) {
            readint(aa); readint(bb);
            ints.push_back(make_pair(aa,bb));
        }

        set<tuple<int,int,int>> curr;
        forr(i,1,w) {  curr.insert(make_tuple(i,0,0));  }
        vector<vector<pair<int,int>>> answer(h+3);
        forr(i,0,h) {
            int addition = modd;
            while (true) {
                auto it = curr.lower_bound(make_tuple(ints[i].first, 0,0));
                if (it==curr.end()) {break;}
                if (get<0>(*it)>ints[i].second) {break;}
                answer[get<2>(*it)+1].push_back(make_pair(1,get<1>(*it)));
                answer[i+2].push_back(make_pair(-1,get<1>(*it)));
                addition = min(addition, get<1>(*it) + ints[i].second+1-get<0>(*it));
                curr.erase(it);
            }
            curr.insert(make_tuple(ints[i].second+1, addition, i+1));
        }

        while (!curr.empty()) {
                if (get<0>(*curr.begin())>w) {break;}
                auto it = curr.begin();
                answer[get<2>(*it)+1].push_back(make_pair(1,get<1>(*it)));
                answer[h+2].push_back(make_pair(-1,get<1>(*it)));
                curr.erase(it);
        }


        if ((ints.front().first==1) && (ints.front().second==w)) {
            forr(i,0,h) {cout << -1 << endl;}
            continue;
        }

        multiset<int> candidates;
        forr(i,1,h+1) {
            for(auto x : answer[i]) {
                if (x.first==1) {
                    candidates.insert(x.second);
                } else {
                    candidates.erase(candidates.find(x.second));
                }
            }
            if (i==1) { continue; }
            if (i==2)  {   cout << 1 << endl; continue;     }
            if (!candidates.empty()) {
                if (*candidates.begin()>w+h+10) { cout << -1 << endl; } else {
                  cout << i+*candidates.begin()-1 << endl; }
            } else {
                cout << -1 << endl;
            }
        }

    }

//    auto end = chrono::steady_clock::now();
//    cerr << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;

    return 0;
}

Measured memory_bytes: 30316