#include <bits/stdc++.h>

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

template <typename T, typename U>
bool chmin(T &a, const U &b){
  return (a > b ? a = b, true : false);
}

template <typename T, typename U>
bool chmax(T &a, const U &b){
  return (a < b ? a = b, true : false);
}

template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
  std::fill((U*)a, (U*)(a + N), v);
}

template <typename T>
auto make_vector(int n, int m, const T &value){
  return std::vector<std::vector<T>>(n, std::vector<T>(m, value));
}

template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
  for(auto it = a.begin(); it != a.end(); ++it){
    if(it != a.begin()) s << " ";
    s << *it;
  }
  return s;
}

template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
  for(auto &x : a) s >> x;
  return s;
}

/**
 * @title Lazy segment tree
 * @docs lazy_segment_tree.md
 */
template <typename Monoid>
class LazySegmentTree{
  using value_type_get = typename Monoid::value_type_get;
  using value_type_update = typename Monoid::value_type_update;
  Monoid M;
  
  const int depth, size, hsize;
  std::vector<value_type_get> data;
  std::vector<value_type_update> lazy;

  void propagate(int i){
    if(lazy[i] == M.id_update()) return;
    if(i < hsize){
      lazy[i << 1 | 0] = M.op_update(lazy[i], lazy[i << 1 | 0]);
      lazy[i << 1 | 1] = M.op_update(lazy[i], lazy[i << 1 | 1]);
    }
    int len = hsize >> (31 - __builtin_clz(i));
    data[i] = M.op(data[i], lazy[i], len);
    lazy[i] = M.id_update();
  }

  value_type_get update_aux(int i, int l, int r, int s, int t, const value_type_update &x){
    propagate(i);
    if(r <= s || t <= l) return data[i];
    else if(s <= l && r <= t){
      lazy[i] = M.op_update(x, lazy[i]);
      propagate(i);
      return data[i];
    }
    else return data[i] = M.op_get(update_aux(i << 1 | 0, l, (l+r) / 2, s, t, x), update_aux(i << 1 | 1, (l+r) / 2, r, s, t, x));
  }
  
  value_type_get get_aux(int i, int l, int r, int x, int y){
    propagate(i);
    if(r <= x || y <= l) return M.id_get();
    else if(x <= l && r <= y) return data[i];
    else return M.op_get(get_aux(i << 1 | 0, l, (l+r) / 2, x, y), get_aux(i << 1 | 1, (l+r) / 2, r, x, y));
  }

public:
  LazySegmentTree(){}
  LazySegmentTree(int n):
    depth(n > 1 ? 32-__builtin_clz(n-1) + 1 : 1),
    size(1 << depth),
    hsize(size / 2),
    data(size, M.id_get()),
    lazy(size, M.id_update())
  {}

  void update(int l, int r, const value_type_update &x){update_aux(1, 0, hsize, l, r, x);}
  void update_at(int i, const value_type_update &x){update(i, i+1, x);}
  value_type_get get(int l, int r){return get_aux(1, 0, hsize, l, r);}
  value_type_get at(int i){return get(i, i+1);}

  template <typename T>
  void init(const T &val){
    init_with_vector(std::vector<T>(hsize, val));
  }

  template <typename T>
  void init_with_vector(const std::vector<T> &val){
    data.assign(size, M.id_get());
    lazy.assign(size, M.id_update());
    for(int i = 0; i < (int)val.size(); ++i) data[hsize + i] = val[i];
    for(int i = hsize-1; i > 0; --i) data[i] = M.op_get(data[i << 1 | 0], data[i << 1 | 1]);
  }
};


/**
 * @title Range affine / Range sum
 * @docs affine_sum.md
 */
template <typename T, typename U>
struct AffineMin{
  using value_type_get = std::optional<T>;
  using value_type_update = std::pair<U, U>;

  value_type_get id_get() const {return {};}
  value_type_update id_update() const {return {1, 0};}

  value_type_get op_get(value_type_get a, value_type_get b) const {
    if(not a) return b;
    if(not b) return a;
    return {std::min(*a, *b)};
  }
  value_type_update op_update(value_type_update a, value_type_update b) const {return {a.first * b.first, a.first * b.second + a.second};}

  value_type_get op(value_type_get a, value_type_update b, int) const {
    assert(b.first == 0 or b.first == 1);
    if(a){
      return {b.first * (*a) + b.second};
    }else{
      return {};
    }
  }
};




namespace solver{
  void init(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(12);
    std::cerr << std::fixed << std::setprecision(12);
    std::cin.exceptions(std::ios_base::failbit);
  }

  constexpr int64_t INF = 1LL << 50;
  
  void solve(){
    int H, W; std::cin >> H >> W;
    std::vector<int> A(H), B(H);
    for(int i = 0; i < H; ++i){
      std::cin >> A[i] >> B[i];
      A[i] -= 1;
      B[i] -= 1;
    }

    LazySegmentTree<AffineMin<int64_t, int64_t>> seg(W);

    seg.init(0);

    std::vector<int64_t> ans(H, INF);

    std::set<int> routes;
    for(int i = 0; i < W; ++i) routes.insert(i);


    for(int i = 0; i < H; ++i){
      dump(routes);
      
      auto it = routes.lower_bound(A[i]);
      if(it != routes.end() and *it <= B[i]){
        int64_t k = INF;
        while(it != routes.end() and *it <= B[i]){
          chmin(k, seg.at(*it).value() + B[i] - *it + 1);
          it = routes.erase(it);
        }
        //dump(k);
        if(B[i] + 1 < W){
          auto t = seg.at(B[i] + 1).value();
          //dump(t);
          seg.update_at(B[i] + 1, {0, std::min<int64_t>(k, t)});
          routes.insert(B[i] + 1);
        }

        seg.update(A[i], B[i] + 1, {0, INF});
      }


      seg.update(0, W, {1, 1});
      //for(int i = 0; i < W; ++i) std::cerr << seg.at(i).value_or(-1) << " ";
      //std::cerr << "\n";



      auto res = seg.get(0, W).value();
      if(res >= INF){
        break;
      }else{
        ans[i] = res;
      }
    }
    
    
    for(auto x : ans) std::cout << (x < INF ? x : -1) << "\n";
  }
}

int main(){
  solver::init();
  while(true){
    try{
      solver::solve();
    }catch(const std::istream::failure &e){
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 32056