#include <bits/stdc++.h>
using namespace std;
#define int long long

int32_t main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);

  int h, w;
  cin >> h >> w;

  set<pair<int, int>> p;
  multiset<int> val;

  for (int i = 1; i <= w; ++i) {
    p.insert({i, i});
    val.insert(0);
  }

  for (int i = 1; i <= h; ++i) {
    int a, b;
    cin >> a >> b;

    auto l = p.lower_bound({a, 0});
    auto r = p.upper_bound({b, w+5});
  
    int end = b+1, start = -1;
    if (b+1 > w) end = 1e15;
    
    while (l != r) {
      int s = (*l).first, f = (*l).second;
      l = p.erase(l);
      val.erase(val.find(s-f));
      start = max(start, f);
    }
  
    if (~start) {
      val.insert(end-start);
      p.insert({end, start});
    }
    
    int ans = *val.begin();
    if (ans > 1e11) ans = -1;
    else ans += i;
    cout << ans << '\n';
  }
}
