#include <bits/stdc++.h>

using namespace std;


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    vector<array<int, 3>> games(n);
    for (int i = 0; i < n; i++) {
        cin >> games[i][0] >> games[i][1];
        games[i][2] = i;
    }

    vector<pair<int, int>> take_left, take_right;
    {  // greedy on beginning
        int last = -1;
        sort(games.begin(), games.end(),
             [](const array<int, 3> &a, const array<int, 3> &b) { return a[1] < b[1]; });
        for (auto [l, r, ind]: games) {
            if (l >= last) {
                take_left.emplace_back(r, ind);
                last = r;
            }
        }
    }
    {  // greedy on the end
        int last = 1e9 + 100;
        sort(games.begin(), games.end(),
             [](const array<int, 3> &a, const array<int, 3> &b) { return a[0] > b[0]; });
        for (auto [l, r, ind]: games) {
            if (r <= last) {
                take_right.emplace_back(l, ind);
                last = l;
            }
        }
    }

    int ans_cnt = -1, last_l = -1, first_r = -1;
    for (int r_ind = 0; r_ind < take_right.size(); r_ind++) {
        auto l_ind = lower_bound(take_left.begin(), take_left.end(),
                                 make_pair(take_right[r_ind].first - k, INT_MAX)) - take_left.begin() - 1;
        if (l_ind < 0) {
            continue;
        }
        if (l_ind + r_ind + 2 > ans_cnt) {
            ans_cnt = l_ind + r_ind + 2;
            last_l = l_ind;
            first_r = r_ind;
        }
    }
    if (ans_cnt == -1) {
        cout << -1 << endl;
    } else {
        cout << ans_cnt << endl;
        for (int i = 0; i <= last_l; i++) {
            cout << take_left[i].second + 1 << " ";
        }
        for (int i = first_r; i > -1; i--) {
            cout << take_right[i].second + 1 << " ";
        }
        cout << endl;
    }
    return 0;
}
