/**
 * Задача "Резиновый рюкзак"
 * 4-я Интернет-олимпиада сезона 2009-2010, усложненный уровень.
 * Автор задачи: Максим Буздалов, buzdalov@rain.ifmo.ru
 * Автор решения: Максим Буздалов, buzdalov@rain.ifmo.ru
 *
 * Корректное решение.
 */

import java.io.*;
import java.util.*;

public class knapsack_mb {
    private static void myAssert(String msg, boolean exp) {
        if (!exp) {
            throw new AssertionError(msg);
        }
    }

    static class Item implements Comparable<Item> {
        public final int volume;
        public final int cost;
        public final int pressure;
        public final int index;

        public Item(int volume, int cost, int pressure, int index) {
            this.volume = volume;
            this.cost = cost;
            this.pressure = pressure;
            this.index = index;
        }

        /**
         * Сортировка в обратном порядке.
         */
        public int compareTo(Item that) {
            return that.pressure - this.pressure;
        }
    }

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader("knapsack.in"));
        int n, v0;
        {
            String ln = in.readLine();
            int ws = ln.indexOf(' ');
            n = Integer.parseInt(ln.substring(0, ws));
            v0 = Integer.parseInt(ln.substring(ws + 1));
            myAssert("n is out of bounds", 1 <= n && n <= 100);
            myAssert("v0 is out of bounds", 0 <= v0 && v0 <= 1000000000);
        }
        Item[] items = new Item[n];
        int sumVolume = 0;
        for (int i = 0; i < n; ++i) {
            String ln = in.readLine();
            int ws1 = ln.indexOf(' ');
            int ws2 = ln.lastIndexOf(' ');
            int v = Integer.parseInt(ln.substring(0, ws1));
            int c = Integer.parseInt(ln.substring(ws1 + 1, ws2));
            int p = Integer.parseInt(ln.substring(ws2 + 1));
            myAssert("v is out of bounds", 1 <= v && v <= 1000);
            myAssert("c is out of bounds", 0 <= c && c <= 1000000);
            myAssert("p is out of bounds", 0 <= p && p <= 1000000000);
            items[i] = new Item(v, c, p, i + 1);
            sumVolume += v;
        }
        Arrays.sort(items);

        int[][] cost = new int[n][sumVolume + 1];
        for (int[] t : cost) {
            Arrays.fill(t, -1);
        }
        cost[0][0] = 0;
        int bestCost = 0;
        int bestRow = 0;
        int bestCol = 0;

        for (int i = 0; i < n; ++i) {
            Item ci = items[i];
            int[] currLayer = cost[i];
            int[] prevLayer = i == 0 ? currLayer : cost[i - 1];
            System.arraycopy(prevLayer, 0, currLayer, 0, currLayer.length);
            for (int v = Math.min(v0 + ci.pressure, sumVolume); v >= ci.volume; --v) {
                if (prevLayer[v - ci.volume] >= 0) {
                    int newCost = ci.cost + prevLayer[v - ci.volume];
                    if (currLayer[v] < newCost) {
                        currLayer[v] = newCost;
                        if (bestCost < newCost) {
                            bestCost = newCost;
                            bestRow = i;
                            bestCol = v;
                        }
                    }
                }
            }
        }

        List<Integer> answer = new ArrayList<Integer>();
        while (bestCol > 0) {
            Item curr = items[bestRow];
            if (bestRow == 0 || cost[bestRow][bestCol] != cost[bestRow - 1][bestCol]) {
                answer.add(curr.index);
                bestCol -= items[bestRow].volume;
            }
            --bestRow;
        }

        PrintWriter out = new PrintWriter("knapsack.out");
        out.println(answer.size() + " " + bestCost);
        for (int i = 0; i < answer.size(); ++i) {
            out.print(answer.get(i));
            if (i + 1 == answer.size()) {
                out.println();
            } else {
                out.print(" ");
            }
        }
        out.close();
    }
}
