#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

template <typename M>
struct SegmentTree_Lazy {
  using T = typename M::T;
  using E = typename M::E;

 private:
  const int height, n;
  vector<T> dat;
  vector<E> laz;

 private:
  inline T reflect(int k) {
    return laz[k] == M::ei() ? dat[k] : M::g(dat[k], laz[k]);
  }
  inline void eval(int k) {
    if (laz[k] == M::ei()) return;
    laz[(k << 1) | 0] = M::h(laz[(k << 1) | 0], laz[k]);
    laz[(k << 1) | 1] = M::h(laz[(k << 1) | 1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = M::ei();
  }
  inline void thrust(int k) {
    for (int i = height; i; i--) eval(k >> i);
  }
  inline void recalc(int k) {
    while (k >>= 1) dat[k] = M::f(reflect((k << 1) | 0), reflect((k << 1) | 1));
  }
  template <typename C>
  int find_subtree(int a, const C& check, T& cur, bool type) {
    while (a < n) {
      eval(a);
      T nxt = type ? M::f(reflect(2 * a + type), cur)
                   : M::f(cur, reflect(2 * a + type));
      if (check(nxt))
        a = 2 * a + type;
      else
        cur = nxt, a = 2 * a + !type;
    }
    return a - n;
  }

 public:
  SegmentTree_Lazy() {}
  SegmentTree_Lazy(int n_, T v1 = M::ti())
      : SegmentTree_Lazy(vector<T>(n_, v1)) {}
  SegmentTree_Lazy(const vector<T>& v)
      : height(ceil(log2(v.size()))),
        n(1 << height),
        dat(n * 2, M::ti()),
        laz(n * 2, M::ei()) {
    for (int i = 0; i < (int)v.size(); i++) dat[i + n] = v[i];
    for (int i = n - 1; i >= 1; i--)
      dat[i] = M::f(dat[i << 1 | 0], dat[i << 1 | 1]);
  }
  void update(int a, int b, E x) {
    thrust(a += n);
    thrust(b += n - 1);
    for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) laz[l] = M::h(laz[l], x), l++;
      if (r & 1) --r, laz[r] = M::h(laz[r], x);
    }
    recalc(a);
    recalc(b);
  }
  void set_val(int a, T x) {
    thrust(a += n);
    dat[a] = x;
    laz[a] = M::ei();
    recalc(a);
  }
  //[a,b)
  T query(int a, int b) {
    thrust(a += n);
    thrust(b += n - 1);
    T vl = M::ti(), vr = M::ti();
    for (int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vl = M::f(vl, reflect(l++));
      if (r & 1) vr = M::f(reflect(--r), vr);
    }
    return M::f(vl, vr);
  }
  T operator[](const int k) { return query(k, k + 1); }
  // min { i : check(query(a,i+1)) = true }
  template <typename C>
  int find_first(const C& check, int a = 0) {
    T vl = M::ti();
    if (a <= 0) {
      if (check(M::f(vl, reflect(1)))) return find_subtree(1, check, vl, false);
      return -1;
    }
    thrust(a + n);
    int b = n;
    for (a += n, b += n; a < b; a >>= 1, b >>= 1)
      if (a & 1) {
        T nxt = M::f(vl, reflect(a));
        if (check(nxt)) return find_subtree(a, check, vl, false);
        vl = nxt;
        ++a;
      }
    return -1;
  }
  // max { i : check(query(i,b)) = true }
  template <typename C>
  int find_last(const C& check, int b = -1) {
    if (b < 0) b = n;
    T vr = M::ti();
    if (b >= n) {
      if (check(M::f(reflect(1), vr))) return find_subtree(1, check, vr, true);
      return -1;
    }
    thrust(b + n - 1);
    int a = 0;
    for (a += n, b += n; a < b; a >>= 1, b >>= 1)
      if (b & 1) {
        T nxt = M::f(reflect(--b), vr);
        if (check(nxt)) return find_subtree(b, check, vr, true);
        vr = nxt;
      }
    return -1;
  }
};

struct Mono {
  using T = pair<int, int>;
  using E = int;
  static T ti() { return make_pair(INT_MAX, INT_MAX); }
  static E ei() { return INT_MAX; }
  static T f(const T& vl, const T& vr) {
    return make_pair(min(vl.first, vr.first), min(vl.second, vr.second));
  }
  static T g(const T& val, const E& op) {
    return op != ei() ? make_pair(op, val.second - val.first + op) : val;
  }
  static E h(const E& opl, const E& opr) { return opr != ei() ? opr : opl; }
};

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  SegmentTree_Lazy<Mono> seg(W);
  for (int i = 0; i < W; i++) seg.set_val(i, make_pair(1, 1 - i));
  const int INF = INT_MAX / 10;
  for (int i = 0; i < H; i++) {
    debugArray(seg, W);
    int A, B;
    cin >> A >> B;
    A--, B--;
    if (B + 1 < W) {
      auto tmp = seg.query(A, B + 1).second;
      if (seg[B + 1].first > tmp + B + 1) {
        seg.set_val(B + 1, make_pair(tmp + B + 1, tmp));
      }
    }
    seg.update(A, B + 1, INF * 2);
    if (A > 0) {
      auto tmp = seg.query(0, A).second;
      if (tmp < INF) {
        seg.set_val(A, make_pair(tmp + A, tmp));
      }
    }
    int ans = seg.query(0, W).first;
    if (ans >= INF)
      ans = -1;
    else
      ans += i;
    cout << ans << '\n';
  }
  debugArray(seg, W);
  return 0;
}


Measured memory_bytes: 11012