#include <bits/stdc++.h>
using namespace std;
template <typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T>
using Edges = vector<edge<T>>;
template <typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T>
using Matrix = vector<vector<T>>;
const long long inf = 1LL << 60;
struct S {
  int left, right, los;
};
int main() {
  int h;
  cin >> h;
  int w;
  cin >> w;
  vector<int> a(h);
  vector<int> b(h);
  for (int i = 0; i < h; i++) {
    cin >> a[i];
    cin >> b[i];
    a[i]--;
    b[i]--;
  }
  vector<int> d(w + 1);
  for (int i = 0; i < (h); i++) {
    d[a[i]]++;
    d[b[i] + 1]--;
  }
  for (int i = 0; i < (w); i++) {
    d[i + 1] += d[i];
  }
  for (int i = 0; i < (w); i++) {
    if (d[i] == 0) {
      for (int j = 0; j < (h); j++) cout << j + 1 << endl;
      return 0;
    }
  }
  vector<S> t;
  t.push_back(S{0, w - 1, 0});
  for (int i = 0; i < h; i++) {
    vector<S> nt;
    if (t.empty()) {
      cout << -1 << endl;
      continue;
    }
    int tmp = 100000010;
    for (auto v : t) {
      int left = v.left;
      int right = v.right;
      if (!nt.empty()) {
        S ts = nt.back();
        if (ts.left == ts.right && ts.right == left) nt.pop_back();
      }
      if (a[i] <= left && right <= b[i]) {
        if (b[i] < w - 1) {
          nt.push_back(S{b[i] + 1, b[i] + 1, v.los + b[i] - right + 1});
          tmp = min(tmp, v.los + b[i] - right + 1);
        }
      } else if (right < a[i] || b[i] < left) {
        nt.push_back(S{left, right, v.los});
        tmp = min(tmp, v.los);
      } else {
        if (left < a[i]) {
          nt.push_back(S{left, a[i] - 1, v.los});
        }
        if (b[i] < right) {
          nt.push_back(S{b[i] + 1, right, v.los});
        }
        tmp = min(tmp, v.los);
      }
    }
    if (nt.empty() || tmp == 100000010) {
      cout << -1 << endl;
      continue;
    }
    t = nt;
    cout << tmp + i + 1 << endl;
  }
  return 0;
}
