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

public class knapsack_aa implements Runnable {

	public static void main(String[] args) {
		new Thread(new knapsack_aa()).start();
	}

	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	boolean eof = false;
	Random rand = new Random(this.hashCode());

	@Override
	public void run() {
		Locale.setDefault(Locale.US);
		try {
			br = new BufferedReader(new FileReader(FNAME + ".in"));
			out = new PrintWriter(FNAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(566);
		}
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return "0";
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	void myAssert(boolean u, String message) {
		if (!u) {
			throw new Error("Assertion failed!!! " + message);
		}
	}

	int inBounds(int x, int l, int r, String name) {
		myAssert(l <= x && x <= r, name + " is not in bounds: " + x
				+ " is not in [" + l + ".." + r + "]");
		return x;
	}

	String FNAME = "knapsack";

	static final int REAL_MAX_VOLUME = 100000;

	class Item implements Comparable<Item> {
		public Item(int v2, int c2, int p2, int i) {
			n = i;
			v = v2;
			c = c2;
			p = p2;
		}

		int v, c, p, n;

		@Override
		public int compareTo(Item i) {
			return i.p - p;
		}
	}

	private void solve() throws IOException {
		int n = inBounds(nextInt(), 1, 100, "n");
		int v0 = inBounds(nextInt(), 0, 1000000000, "v0");
		Item[] a = new Item[n];
		for (int i = 0; i < a.length; i++) {
			a[i] = new Item(inBounds(nextInt(), 1, 1000, "v[" + (i + 1) + "]"),
					inBounds(nextInt(), 0, 1000000, "c[" + (i + 1) + "]"),
					inBounds(nextInt(), 0, 1000000000, "p[" + (i + 1) + "]"), i);
		}
		Arrays.sort(a);
		int[][] d = new int[n + 1][REAL_MAX_VOLUME + 1];
		for (int i = 0; i + 1 < d.length; i++) {
			for (int j = 0; j < d[i].length; j++) {
				d[i + 1][j] = d[i][j];
			}
			for (int j = 0; j + a[i].v < d[i].length
					&& j + a[i].v - v0 <= a[i].p; j++) {
				if (d[i + 1][j + a[i].v] < d[i][j] + a[i].c) {
					d[i + 1][j + a[i].v] = d[i][j] + a[i].c;
				}
			}
		}
		int maxi = -1;
		int maxj = -1;
		int max = -1;
		for (int i = 0; i < d.length; i++) {
			for (int j = 0; j < d[i].length; j++) {
				if (max < d[i][j]) {
					max = d[i][j];
					maxi = i;
					maxj = j;
				}
			}
		}
		ArrayList<Integer> al = new ArrayList<Integer>();
		while (maxi > 0) {
			if (d[maxi - 1][maxj] != d[maxi][maxj]) {
				maxj -= a[maxi - 1].v;
				al.add(a[maxi - 1].n + 1);
			}
			maxi--;
		}
		out.println(al.size() + " " + max);
		for (int i : al) {
			out.print(i + " ");
		}
	}
}
