#include <bits/stdc++.h>
using namespace std;

int main()
{
    size_t H, W;
    cin >> H >> W;

    vector<size_t> A(H);
    vector<size_t> B(H);
    for (size_t i = 0; i < H; i++)
    {
        cin >> A[i] >> B[i];
    }

    set<pair<size_t, size_t>> goal_start;
    set<pair<int, size_t>> ans;
    for (size_t i = 1; i <= W; i++)
    {
        goal_start.insert(make_pair(i, i));
        ans.insert(make_pair(0, i));
    }

    for (size_t i = 0; i < H; i++)
    {
        size_t start = 0;
        size_t right = 0;
        for (
            set<pair<size_t, size_t>>::iterator itr = goal_start.lower_bound(make_pair(A[i], 0));
            itr != goal_start.end() && itr->first <= B[i];
            itr = goal_start.erase(itr))
        {
            size_t goal = itr->first;
            start = itr->second;

            ans.erase(make_pair(goal - start, goal));
            right = max(right, start);
        }
        if (start > 0 && B[i] < W)
        {
            goal_start.insert(make_pair(B[i] + 1, right));
            ans.insert(make_pair(B[i] + 1 - right, B[i] + 1));
        }

        if (ans.empty())
        {
            cout << -1 << endl;
        }
        else
        {
            cout << i + 1 + ans.begin()->first << endl;
        }
    }
}
