#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;
}

namespace haar_lib {
  template <typename MonoidGet, typename MonoidUpdate, template <typename, typename> typename Connector>
  class lazy_segment_tree {
    using value_type_get = typename MonoidGet::value_type;
    using value_type_update = typename MonoidUpdate::value_type;
    Connector<MonoidGet, MonoidUpdate> M;
    MonoidGet M_get;
    MonoidUpdate M_update;

    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_update()) return;
      if(i < hsize){
        lazy[i << 1 | 0] = M_update(lazy[i], lazy[i << 1 | 0]);
        lazy[i << 1 | 1] = M_update(lazy[i], lazy[i << 1 | 1]);
      }
      int len = hsize >> (31 - __builtin_clz(i));
      data[i] = M(data[i], lazy[i], len);
      lazy[i] = M_update();
    }

    void propagate_top_down(int i){
      std::vector<int> temp;
      while(i > 1){
        i >>= 1;
        temp.push_back(i);
      }

      for(auto it = temp.rbegin(); it != temp.rend(); ++it) propagate(*it);
    }

    void bottom_up(int i){
      while(i > 1){
        i >>= 1;
        propagate(i << 1 | 0);
        propagate(i << 1 | 1);
        data[i] = M_get(data[i << 1 | 0], data[i << 1 | 1]);
      }
    }

  public:
    lazy_segment_tree(){}
    lazy_segment_tree(int n):
      depth(n > 1 ? 32 - __builtin_clz(n - 1) + 1 : 1),
      size(1 << depth),
      hsize(size / 2),
      data(size, M_get()),
      lazy(size, M_update())
    {}

    void update(int l, int r, const value_type_update &x){
      propagate_top_down(l + hsize);
      if(r < hsize) propagate_top_down(r + hsize);

      int L = l + hsize, R = r + hsize;

      while(L < R){
        if(R & 1){
          --R;
          lazy[R] = M_update(x, lazy[R]);
          propagate(R);
        }
        if(L & 1){
          lazy[L] = M_update(x, lazy[L]);
          propagate(L);
          ++L;
        }
        L >>= 1;
        R >>= 1;
      }

      bottom_up(l + hsize);
      if(r < hsize) bottom_up(r + hsize);
    }

    void update_at(int i, const value_type_update &x){update(i, i + 1, x);}

    value_type_get get(int l, int r){
      propagate_top_down(l + hsize);
      if(r < hsize) propagate_top_down(r + hsize);

      value_type_get ret_left = M_get(), ret_right = M_get();

      int L = l + hsize, R = r + hsize;

      while(L < R){
        if(R & 1){
          --R;
          propagate(R);
          ret_right = M_get(data[R], ret_right);
        }
        if(L & 1){
          propagate(L);
          ret_left = M_get(ret_left, data[L]);
          ++L;
        }
        L >>= 1;
        R >>= 1;
      }

      return M_get(ret_left, ret_right);
    }

    value_type_get operator[](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_get());
      lazy.assign(size, M_update());
      for(int i = 0; i < (int)val.size(); ++i) data[hsize + i] = (value_type_get)val[i];
      for(int i = hsize - 1; i > 0; --i) data[i] = M_get(data[i << 1 | 0], data[i << 1 | 1]);
    }
  };
}

namespace haar_lib {
  template <typename T>
  struct affine_monoid {
    using value_type = std::pair<T, T>;
    value_type operator()() const {return std::make_pair(1, 0);}
    value_type operator()(const value_type &a, const value_type &b) const {
      return std::make_pair(a.first * b.first, a.first * b.second + a.second);
    }
  };
}

namespace haar_lib {
  namespace min_max_monoid_impl {
    template <typename T>
    struct inner_value {
      std::optional<T> min, max;
      inner_value(): min(std::nullopt), max(std::nullopt){}
      inner_value(T value): min(value), max(value){}
    };
  }

  template <typename T>
  struct min_max_monoid {
    using value_type = min_max_monoid_impl::inner_value<T>;

    value_type operator()() const {
      return {};
    }

    value_type operator()(const value_type &a, const value_type &b) const {
      value_type ret;
      if(not a.min) ret.min = b.min;
      if(not b.min) ret.min = a.min;
      if(a.min and b.min) ret.min = std::min(a.min.value(), b.min.value());

      if(not a.max) ret.max = b.max;
      if(not b.max) ret.max = a.max;
      if(a.max and b.max) ret.max = std::max(a.max.value(), b.max.value());

      return ret;
    }
  };
}

namespace haar_lib {
  template <typename MonoidGet, typename MonoidUpdate>
  struct affine_min_max {
    using value_type_get = typename MonoidGet::value_type;
    using value_type_update = typename MonoidUpdate::value_type;

    value_type_get operator()(const value_type_get &a, const value_type_update &b, int) const {
      value_type_get ret;
      if(b.first >= 0){
        if(a.min) ret.min = b.first * (a.min.value()) + b.second;
        if(a.max) ret.max = b.first * (a.max.value()) + b.second;
      }else{
        if(a.min) ret.max = b.first * (a.min.value()) + b.second;
        if(a.max) ret.min = b.first * (a.max.value()) + b.second;
      }

      return ret;
    }
  };
}



namespace solver{
  using namespace haar_lib;

  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;
    }

    lazy_segment_tree<min_max_monoid<int64_t>, affine_monoid<int64_t>, affine_min_max> 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){
      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[*it].min.value() + B[i] - *it + 1);
          it = routes.erase(it);
        }

        if(B[i] + 1 < W){
          auto t = seg[B[i] + 1].min.value();
          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});

      auto res = seg.get(0, W).min.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: 40368