//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;


const llong INF = 1e12 + 10;

struct SegmentTreeNode {
   llong val;
   llong delay_arith_val;
   int delay_incr_val;
   SegmentTreeNode(llong _val = 0)
      : val(_val), delay_arith_val(0), delay_incr_val(0) { }
   SegmentTreeNode operator+(const SegmentTreeNode& R) const {
      SegmentTreeNode res;
      res.val = min(this->val, R.val);
      return res;
   }
   void update(int L, int R, long long d) {
   // cerr << "UPD  L:" << L << "   R:" << R << "  d:" << d << endl;
      val             = d;
      delay_arith_val = d;
      delay_incr_val  = 0;
   }
   void increase(int L, int R, int d) {
      val            += d;
      if (delay_arith_val)
         delay_arith_val += d;
      else
         delay_incr_val += d;
   }
   void propagate(SegmentTreeNode& pL, SegmentTreeNode& pR, int L, int R) {
      if (delay_arith_val) {
         const int mid = (L+R)/2;
         pL.update(L, mid, delay_arith_val);
         pR.update(mid+1, R, delay_arith_val + (mid-L+1));
         delay_arith_val  = 0;
         delay_incr_val = 0;
      }
      else if (delay_incr_val) {
         const int mid = (L+R)/2;
         pL.increase(L, mid, delay_incr_val);
         pR.increase(mid+1, R, delay_incr_val);
         delay_incr_val = 0;
      }
   }
};

class SegmentTree {

   void _update(int p, int q, llong val, int node, int L, int R);
   void _increase(int p, int q, int node, int L, int R);
   llong _query(int p, int node, int L, int R);
public:
   int N;
   vector<SegmentTreeNode> tree;

   SegmentTree(int _N) : N(_N), tree(4*_N+1) {
   }
   void update(int p, int q, llong val) {
      if (p > q) return;
      _update(p, q, val, 1, 0, N-1);
   }
   void increase(int p, int q) {
      if (p > q) return;
      _increase(p, q, 1, 0, N-1);
   }
   llong query(int p) {
      return _query(p, 1, 0, N-1);
   }
   llong min() {
      return tree[1].val;
   }
};

void SegmentTree::_update(int p, int q, llong val, int node, int L, int R) {
   if (q < L || p > R) return;
   if (p <= L && R <= q) {
      tree[node].update(L, R, L-p+val);
      return;
   }
   tree[node].propagate(tree[2*node], tree[2*node+1], L, R);
   const int mid = (L+R)/2;
   _update(p, q, val, 2*node, L, mid);
   _update(p, q, val, 2*node+1, mid+1, R);
   tree[node] = tree[2*node] + tree[2*node+1];
}

void SegmentTree::_increase(int p, int q, int node, int L, int R) {
   if (q < L || p > R) return;
   if (p <= L && R <= q) {
      tree[node].increase(L, R, 1);
      return;
   }
   tree[node].propagate(tree[2*node], tree[2*node+1], L, R);
   const int mid = (L+R)/2;
   _increase(p, q, 2*node, L, mid);
   _increase(p, q, 2*node+1, mid+1, R);
   tree[node] = tree[2*node] + tree[2*node+1];
}

llong SegmentTree::_query(int pos, int node, int L, int R) {
   assert(L <= pos && pos <= R);

   if (L == R)
      return tree[node].val;

   tree[node].propagate(tree[2*node], tree[2*node+1], L, R);
   const int mid = (L+R)/2;
   if (pos <= mid)
      return _query(pos, 2*node, L, mid);
   else
      return _query(pos, 2*node+1, mid+1, R);
}


struct Range {
   int L, R;
};

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int H, W;
   cin >> H >> W;

   SegmentTree st(W+1);
   st.update(0, 0, INF);

   vector<Range> blocked(H+1);
   FOR(i, 1, H) {
      int L, R;
      cin >> L >> R;
      blocked[i] = {L, R};

      st.increase(1, L-1);
      llong start = st.query(L-1);
      st.update(L, R, start+1);
      st.increase(R+1, W);
      
      llong res = st.min();
      cout << (res < INF ? res : -1) << '\n';
   }

   return 0;
}


Measured memory_bytes: 23504