#include <bits/stdc++.h>

const int N = 200010;

struct Edge{
    int start, end;

    bool operator <(const Edge &e)const{
        return end < e.end;
    }
};

int a[N], b[N];

int main(){
    int h, w;
    scanf("%d%d", &h, &w);
    for (int i = 0; i < h; ++ i){
        scanf("%d%d", &a[i], &b[i]);
    }
    std::set <Edge> set;
    for (int i = 1; i <= w; ++ i){
        set.insert(Edge{i, i});
    }
    std::multiset <int> answer;
    for (int i = 1; i <= w; ++ i){
        answer.insert(0);
    }
    for (int i = 0; i < h; ++ i){
        auto u = set.lower_bound(Edge{0, a[i]});
        int max = 0;
        while (u != set.end() && u -> end <= b[i] + 1){
            auto v = answer.find(u -> end - u -> start);
            answer.erase(v);
            max = std::max(max, u -> start);
            u = set.erase(u);
        }
        if (max > 0 && b[i] + 1 <= w){
            set.insert(Edge{max, b[i] + 1});
            answer.insert(b[i] + 1 - max);
        }
        if (answer.empty()){
            puts("-1");
            continue;
        }
        printf("%d\n", *(answer.begin()) + i + 1);
    }
    return 0;
}