program check_d;

uses
  testlib{, symbols};

var
  ja, pa, i, j, k, l, m, n, p: longint;
  t, z, y: array [0..100] of longint;
  f: boolean;

begin
  m := inf.readlongint;
  n := inf.readlongint;
  for i := 1 to n do
  begin
    t[i] := inf.readlongint;
    z[i] := inf.readlongint;
    y[i] := inf.readlongint;
  end;

  ja := ans.readlongint;
  pa := ouf.readlongint;

  if ja <> pa then
    quit(_wa, 'time wrong, expected: , found: ');

  p := 0;
  f := false;
  for i := 1 to n do
  begin
    k := ouf.readlongint;
    if k > 0 then
      l := t[i] * k + ((k - 1) div z[i]) * y[i]
    else
      l := 0;
    if l > pa then
      quit(_wa, 'th volunteer has time limit exceeded');
    if l = pa then
      f := true;
    p := p + k;
  end;
  if not f then
    quit(_fail, 'faster !!!');
  if p <> m then
    quit(_wa, 'wrong number of baloons, must be: , made: ');

  quit(_ok, '');
end.
