uses
  testlib, SysUtils, Math;

const
  MAXN = 16;

var
  n, m, i, j, jans, pans, time, cost, w : integer;
  t, p, k : array[1..MAXN] of integer;
  done : array[1..MAXN] of boolean;
  tab : array[1..MAXN, 1..MAXN] of integer;

begin
  n := inf.readlongint;
  m := inf.readlongint;
  for i := 1 to n do begin
    t[i] := inf.readlongint;
    p[i] := inf.readlongint;
    k[i] := inf.readlongint;
    for j := 1 to k[i] do begin
      tab[i][j] := inf.readlongint;
    end;
  end;
  jans := ans.readlongint;
  pans := ouf.readlongint;

  time := 0;
  cost := 0;
  while (not(ouf.seekeof)) do begin
    w := ouf.readlongint;
    if (w < 1) or (w > n) then
      quit(_wa, 'Wrong number of work: ' + IntToStr(w));
    if (done[w]) then
      quit(_wa, 'Work is already done: ' + IntToStr(w));
    if (time + t[w] > m) then
      quit(_wa, 'Not enough time to complete all works');
    for i := 1 to k[w] do begin
      if (not(done[tab[w][i]])) then
        quit(_wa, 'Work ' + IntToStr(tab[w][i]) + ' is not completed before work ' + IntToStr(w));
    end;
    time := time + t[w];
    cost := cost + p[w];
    done[w] := true;
  end;
  if (cost <> pans) then
    quit(_wa, 'Real cost: ' + IntToStr(cost) + ', but stated: ' + IntToStr(pans));
  if (pans > jans) then
    quit(_fail, 'Contestant found better solution');
  if (jans > pans) then
    quit(_wa, 'Not best solution');
  quit(_ok, 'Cost: ' + IntToStr(pans));
end.