import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    auto W = hw[1];

    int w = 1;
    long s;
    foreach (_; 0..H) {
        auto ab = readln.split.to!(int[]);
        auto A = ab[0];
        auto B = ab[1];
        if (w == -1) {
            writeln(-1);
        } else if (w < A || B < w) {
            s += 1;
            writeln(s);
        } else {
            s += B - w + 1;
            w = B+1;
            if (w > W) {
                w = -1;
                writeln(-1);
            } else {
                s += 1;
                writeln(s);
            }
        }
    }
}