#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = my_getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = my_getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
template <class T> struct LHeap{
  int *hp;
  int *place;
  int size;
  T *val;
  void malloc(int N){
    hp = (int*)std::malloc(N*sizeof(int));
    place=(int*)std::malloc(N*sizeof(int));
    val=(T*)std::malloc(N*sizeof(T));
  }
  void walloc(int N, void **mem=&wmem){
    walloc1d(&hp, N, mem);
    walloc1d(&place, N, mem);
    walloc1d(&val, N, mem);
  }
  void free(){
    std::free(hp);
    std::free(place);
    std::free(val);
  }
  void init(int N){
    int i;
    size=0;
    for(i=(0);i<(N);i++){
      place[i]=-1;
    }
  }
  void up(int n){
    int m;
    while(n){
      m=(n-1)/2;
      if(val[hp[m]]<=val[hp[n]]){
        break;
      }
      swap(hp[m],hp[n]);
      swap(place[hp[m]],place[hp[n]]);
      n=m;
    }
  }
  void down(int n){
    int m;
    for(;;){
      m=2*n+1;
      if(m>=size){
        break;
      }
      if(m+1<size&&val[hp[m]]>val[hp[m+1]]){
        m++;
      }
      if(val[hp[m]]>=val[hp[n]]){
        break;
      }
      swap(hp[m],hp[n]);
      swap(place[hp[m]],place[hp[n]]);
      n=m;
    }
  }
  void change(int n, T v){
    T f = val[n];
    val[n] = v;
    if(place[n]==-1){
      place[n] = size;
      hp[size++] = n;
      up(place[n]);
    }
    else{
      if(f < v){
        down(place[n]);
      }
      else if(f > v){
        up(place[n]);
      }
    }
  }
  int pop(void){
    int res = hp[0];
    place[res] = -1;
    size--;
    if(size){
      hp[0]=hp[size];
      place[hp[0]]=0;
      down(0);
    }
    return res;
  }
}
;
int H;
int W;
int A;
int B;
int arr[200000];
int main(){
  int i;
  wmem = memarr;
  int ad;
  int res;
  set<pair<int,int>> s;
  set<pair<int,int>>::iterator it;
  pair<int,int> p;
  LHeap<int> hp;
  rd(H);
  rd(W);
  for(i=(0);i<(W);i++){
    s.insert(make_pair(i,0));
  }
  hp.malloc(W);
  hp.init(W);
  for(i=(0);i<(W);i++){
    hp.change(i, 0);
  }
  for(ad=(0);ad<(H);ad++){
    rd(A);A += (-1);
    rd(B);B += (-1);
    if(s.size() == 0){
      wt_L(-1);
      wt_L('\n');
      continue;
    }
    for(;;){
      it = s.lower_bound(make_pair(A, -1));
      if(it == s.end()){
        break;
      }
      if(it->first > B){
        break;
      }
      p = *it;
      s.erase(it);
      arr[p.first] = 1073709056;
      hp.change(p.first, 1073709056);
      if(B+1 < W && arr[B+1] > B+1 - p.first + p.second){
        it = s.lower_bound(make_pair(B+1, -1));
        if(it != s.end() && it->first == B+1){
          s.erase(it);
        }
        arr[B+1] = B+1 - p.first + p.second;
        s.insert(make_pair(B+1, arr[B+1]));
        hp.change(B+1, arr[B+1]);
      }
    }
    if(s.size() == 0){
      wt_L(-1);
      wt_L('\n');
      continue;
    }
    res = hp.val[hp.hp[0]] + ad + 1;
    wt_L(res);
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20200813-1 [beta]

// --- original code ---
// int H, W, A, B;
// int arr[2d5];
// {
//   int ad, res;
//   set<pair<int,int>> s;
//   set<pair<int,int>>::iterator it;
//   pair<int,int> p;
//   LHeap<int> hp;
// 
//   rd(H,W);
// 
//   rep(i,W) s.insert(make_pair(i,0));
//   hp.malloc(W);
//   hp.init(W);
//   rep(i,W) hp.change(i, 0);
// 
//   rep(ad,H){
//     rd(A--, B--);
//     if(s.size() == 0) wt(-1), continue;
// 
//     for(;;){
//       it = s.lower_bound(make_pair(A, -1));
//       if(it == s.end()) break;
//       if(it->first > B) break;
//       p = *it;
//       s.erase(it);
//       arr[p.first] = int_inf;
//       hp.change(p.first, int_inf);
//       if(B+1 < W && arr[B+1] > B+1 - p.first + p.second){
//         it = s.lower_bound(make_pair(B+1, -1));
//         if(it != s.end() && it->first == B+1) s.erase(it);
//         arr[B+1] = B+1 - p.first + p.second;
//         s.insert(make_pair(B+1, arr[B+1]));
//         hp.change(B+1, arr[B+1]);
//       }
//     }
// 
// //    wt(A,B,":",arr(W));
// 
//     if(s.size() == 0) wt(-1), continue;
//     res = hp.val[hp.hp[0]] + ad + 1;
//     wt(res);
//   }
// }


Measured memory_bytes: 18024