uses
  Math;

const
  maxn = 100;
  maxv = 1000 * maxn;
  inf = 1000000000;

var
  tab : array[0..maxn, 0..maxv] of integer;
  b : array[0..maxn, 0..maxv] of boolean;
  maxc, sum, cc, maxi, i, j, n, v0 : integer;
  v, p, c, num : array[1..maxn] of integer;
  u : array[1..maxn] of boolean;

procedure swap(var a : integer; var b : integer);
var
  t : integer;
begin
  t := a;
  a := b;
  b := t;
end;

begin
  reset(input, 'knapsack.in');
  rewrite(output, 'knapsack.out');
  read(n, v0);
  sum := 0;
  for i := 1 to n do begin
    read(v[i], c[i], p[i]);
    num[i] := i;
    sum := sum + v[i];
  end;
  for i := 1 to n do begin
    for j := i + 1 to n do begin
      if (p[i] < p[j]) then begin
        swap(p[i], p[j]);
        swap(v[i], v[j]);
        swap(c[i], c[j]);
        swap(num[i], num[j]);
      end;
    end;
  end;
  for i := 1 to sum do begin
    tab[0][i] := -inf;
  end;
  tab[0][0] := 0;
  for i := 1 to n do begin
    for j := 0 to min(sum, v0 + p[i]) - v[i] do begin
      if (tab[i][j + v[i]] < tab[i - 1][j] + c[i]) then begin
        tab[i][j + v[i]] := tab[i - 1][j] + c[i];
        b[i][j + v[i]] := true;
      end;
    end;
    for j := 0 to sum do begin
      if (tab[i][j] < tab[i - 1][j]) then begin
        tab[i][j] := tab[i - 1][j];
        b[i][j] := false;
      end;
    end;
  end;
  maxc := 0;
  maxi := 0;
  for i := 1 to sum do begin
    if (tab[n][i] > maxc) then begin
      maxc := tab[n][i];
      maxi := i;
    end;
  end;
  i := n;
  j := maxi;
  cc := 0;
  while (i > 0) do begin
    if (b[i][j]) then begin
      cc := cc + 1;
      u[i] := true;
      j := j - v[i];
    end;
    i := i - 1;
  end;
  writeln(cc, ' ', maxc);
  for i := 1 to n do begin
    if (u[i]) then begin
      write(num[i], ' ');
    end;
  end;
end.