#include <bits/stdc++.h>
using namespace std;
vector<int> dist, profit;
int stop_count, min_dist;
vector<vector<pair<int, int>>> memo;
int solve(int n, int before) {
if(n == stop_count+1) return 0;
else if (memo[n][before] != pair(-1, -1)) return memo[n][before].first;
int answer = 0;
int b = solve(n + 1, before);
if (dist[n] - dist[before] >= min_dist) {
answer = profit[n] + solve(n+1, n);
}
if (answer > b) {
memo[n][before] = {answer, 0};
} else {
memo[n][before] = {b, 1};
}
return memo[n][before].first;
}
int main() {
cin >> stop_count >> min_dist;
dist.assign(stop_count +1, 0);
profit.assign(stop_count +1, 0);
dist[0] = 0 - min_dist - 1;
profit[0] = 0 - min_dist - 1;
memo.assign(stop_count + 1, vector<pair<int, int>>(stop_count+1, {-1, -1}));
for (int i = 1; i <= stop_count; i++) {
cin >> dist[i] >> profit[i];
}
cout << solve(1, 0) << endl;
vector<int> stations;
int actual = 1;
int before = 0;
while(actual <= stop_count) {
if(memo[actual][before].second == 0) {
stations.push_back(actual);
before = actual++;
} else {
actual++;
}
}
cout << stations.size() << " ";
for (int x : stations) {
cout << x << " ";
}
}