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

public class rpg_sk implements Runnable {
	public static void rpg_sk(String[] args) {
		Locale.setDefault(Locale.US);
		new Thread(new rpg_sk()).start();
	}
	
	StringTokenizer st;
	BufferedReader in;
	PrintWriter out;
	final String FILE = "rpg";
	
	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens())) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}
	
	public void run() {
		try {
			in = new BufferedReader(new FileReader(FILE + ".in"));
			out = new PrintWriter(FILE + ".out");
			solution();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}
	
	int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	int n, m;
	int[] t, b;
	int[][] p;
	boolean[] u;
	int[] o;
	int oc;
	
	void solution() throws Exception {
		n = nextInt();
		m = nextInt();
		t = new int[n];
		b = new int[n];
		p = new int[n][];
		
		for (int i = 0; i < n; i++) {
			t[i] = nextInt();
			b[i] = nextInt();
			int k = nextInt();
			p[i] = new int[k];
			for (int j = 0; j < k; j++) {
				p[i][j] = nextInt() - 1;
			}
		}
		
		u = new boolean[n];
		o = new int[n];
		oc = 0;
		
		boolean f = true;
		for (int i = 0; (i < n) && f; i++) {
			f = false;
			for (int j = 0; (j < n) && (!f); j++) {
				if (!u[j]) {
					boolean g = true;
					for (int k : p[j]) {
						g &= u[k];
					}
					
					if (g) {
						u[j] = true;
						o[oc] = j;
						oc++;
						f = true;
						break;
					}
				}
			}
		}
		
		int[] bs = new int[1 << n];
		int[] ut = new int[1 << n];
		
		Arrays.fill(bs, -1);
		Arrays.fill(ut, 0);
	
		bs[0] = 0;
		ut[0] = 0;
		HashSet<Integer> u = new HashSet<Integer>();
		u.add(0);
	
		for (int kd = 0; kd < oc; kd++) {
			HashSet<Integer> nu = new HashSet<Integer>(u);
			
			int j = o[kd];
			for (int ma : u) {
				boolean g = true;
				for (int k : p[j]) {
					g &= ((ma >> k) % 2 == 1);
				}
				if (g && (ut[ma] + t[j] <= m)) {
					int nm = ma + (1 << j);
					ut[nm] = ut[ma] + t[j];
					bs[nm] = bs[ma] + b[j];
					nu.add(nm);
				}
			}
			
			u = nu;
		}
		
		int mm = -1;
		for (int m : u) {
			if ((mm < 0) || (bs[mm] < bs[m])) {
				mm = m;
			}
		}
		
		out.println(bs[mm]);
		for (int i = 0; i < oc; i++) {
			int j = o[i];
			if ((mm >> j) % 2 == 1) {
				out.print((j + 1) + " ");
			}
		}
		
	}
}