#include <algorithm>
#include <fstream>
#include <set>
#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];

struct cmp
{
    bool operator () (int const &a, int const &b) const
    {
        return c[a] * v[b] > c[b] * v[a];
    }
};

void greedy(int n, int vv)
{
    std::sort(idx, idx + n, cmp());
    int sum_c = 0;
    int sum_v = 0;
    int cnt = 0;
    for (int i = 0; i < n; ++i) 
    {
        int j = idx[i];
        if (sum_v + v[j] <= vv) 
        {
            sum_v += v[j];
            sum_c += c[j];
            curr[cnt++] = j;
        }
    }
    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;
    }

    std::set<int> pressures;
    pressures.insert(0);
    for (int i = 0; i < n; ++i)
    {
        pressures.insert(p[i]);
    }
    
    for (std::set<int>::const_iterator it = pressures.begin(); it != pressures.end(); ++it)
    {
        int cnt = 0;
        for (int i = 0; i < n; ++i)
        {
            if (p[i] >= *it)
            {
                idx[cnt++] = i;
            }
        }
        greedy(cnt, v0 + *it);
    }
    
    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;
}
