#include <algorithm>
#include <fstream>
#include <vector>

int v[100];
int c[100];
int p[100];

int idx[100];

int n, v0;

int best[100];
int best_n = 0;
int best_cost = 0;

int curr[100];

void test()
{
    int max_pressure = 1000000000;
    int cnt = 0;
    int sum_v = 0;
    int sum_c = 0;
    for (int i = 0; i < n; ++i)
    {
        int j = idx[i];
        int curr_pressure = std::min(max_pressure, p[j]);
        if (sum_v + v[j] <= v0 + curr_pressure)
        {
            sum_c += c[j];
            sum_v += v[j];
            curr[cnt++] = j;
            max_pressure = curr_pressure;
        }
    }
    if (sum_c > best_cost)
    {
        best_cost = sum_c;
        best_n = cnt;
        for (int i = 0; i < cnt; ++i)
        {
            best[i] = curr[i];
        }
    }
}

int main()
{
    std::ifstream in("knapsack.in");
    in >> n >> v0;
    for (int i = 0; i < n; ++i)
    {
        in >> v[i] >> c[i] >> p[i];
        idx[i] = i;
    }
    
    test();
    std::reverse(idx, idx + n);
    test();
    
    for (int t = 0; t < 100000000; t += n)
    {
        std::random_shuffle(idx, idx + n);
        test();
    }
    
    std::ofstream out("knapsack.out");
    out << best_n << " " << best_cost << std::endl;
    for (int i = 0; i < best_n; ++i)
    {
        out << 1 + best[i] << " ";
    }
    out << std::endl;
    return 0;
}
