uses
  testlib, SysUtils;

const
  maxn = 20;

var
  n, k, ja, pa, i, m : longint;
  a, b, c : array[1..maxn] of longint;

begin
  n := inf.readlongint;
  k := inf.readlongint;
  for i := 1 to n do begin
    a[i] := inf.readlongint;
    b[i] := inf.readlongint;
    c[i] := inf.readlongint;
  end;
  ja := ans.readlongint;
  pa := ouf.readlongint;
  if (pa < 0) or (pa > n) then
    quit(_wa, 'Wrong count: ' + IntToStr(pa));
  if (pa < ja) then
    quit(_wa, IntToStr(pa) + ' meetings instead of ' + IntToStr(ja));
  for i := 1 to pa do begin
    m := ouf.readlongint;
    if (m < 1) or (m > n) then
      quit(_wa, 'Wrong number of meeting: ' + IntToStr(m));
    if (k < a[m]) or (k > b[m]) then
      quit(_wa, 'Cannot make meeting number ' + IntToStr(i));
    k := k + c[m];
  end;
  if (pa > ja) then
    quit(_fail, 'Contestant found better answer');
  quit(_ok, IntToStr(pa) + ' meetings');
end.