#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main() {
  int h, w; cin >> h >> w;
  set<pair<int, int>> S, T;
  rep(i, w) S.emplace(i, 0), T.emplace(0, i);

  rep(k, h) {
    int a, b; cin >> a >> b; --a;
    auto l = S.lower_bound({a, -1});
    auto r = S.lower_bound({b, -1});

    int x = w;
    while (l != r) {
      auto [i, j] = *l;
      x = min(x, j-i+b);
      l = S.erase(l);
      T.erase({j, i});
    }
    if (x < w && b < w) S.emplace(b, x), T.emplace(x, b);

    int ans = -1;
    if (!T.empty()) ans = k+1 + T.begin()->first;
    cout << ans << '\n';
  }
}
