uses
  Math;

const
  maxn = 16;

var
  n, m, i, nn, j, sumt, ii, jj : integer;
  t, p, k : array[1..maxn] of integer;
  tab : array[1..maxn, 1..maxn] of integer;
  last, d : array[0..1 shl maxn - 1] of integer;
  can : boolean;

procedure writeans(i : integer);
begin
  if (i = 0) then
    exit;
  writeans(i xor (1 shl (last[i] - 1)));
  write(last[i], ' ');
end;

begin
  reset(input, 'rpg.in');
  rewrite(output, 'rpg.out');
  read(n, m);
  m := m + 1;
  for i := 1 to n do begin
    read(t[i], p[i], k[i]);
    for j := 1 to k[i] do begin
      read(tab[i][j]);
    end;
  end;
  nn := 1 shl n;
  for i := 1 to nn - 1 do begin
    d[i] := -1;
  end;
  for i := 1 to nn - 1 do begin
    sumt := 0;
    for j := 1 to n do begin
      if (i and (1 shl (j - 1)) <> 0) then
        sumt := sumt + t[j];
    end;
    if (sumt > m) then
      continue;
    for j := 1 to n do begin
      if (i and (1 shl (j - 1)) <> 0) then begin
        ii := i xor (1 shl (j - 1));
        if (d[ii] < 0) then
          continue;
        can := true;
        for jj := 1 to k[j] do begin
          if (i and (1 shl (tab[j][jj] - 1)) = 0) then begin
            can := false;
            break;
          end;
        end;
        if (can) then begin
          if (d[i] = -1) or (d[i] < d[ii] + p[j]) then begin
            d[i] := d[ii] + p[j];
            last[i] := j;
          end;
        end;
      end;
    end;
  end;
  j := 0;
  for i := 1 to nn - 1 do begin
    if (d[i] >= 0) and (d[i] > d[j]) then
      j := i;
  end;
  writeln(d[j]);
  writeans(j);
end.