// Проверяющая программа для задачи "Призыв в армию"
// Федор Царев
{$apptype console}
{$o-,r+,q+}
uses
  sysutils, math, testlib;

type
  int = longint;

const
  MAXN = 100;
  MAXM = 100;
  MAXK = 300;

function s2n(param : string) : int;
begin
  if (param = 'STRENGTH') then begin
  	result := 1;
  end else if (param = 'HEIGHT') then begin
	result := 2;  	
  end else if (param = 'WEIGHT') then begin
  	result := 3;
  end else begin
  	result := -1;
  end;
end;

var
  n, k, m : int;
  ja, pa : int;
  fakeP : array[1..MAXN, 1..3] of int;
  realP : array[1..MAXN, 1..3] of int;
  i, j : int;
  pc : int;
  realPA : int;
  examNum : int;
  examType : int;
  examTypeStr : string;
  takeNum : int;
  prev : int;

begin
  n := inf.readLongint();
  m := inf.readLongint();
  k := inf.readLongint();
  for i := 1 to n do begin
    for j := 1 to 3 do begin
      fakeP[i][j] := inf.readLongint();
    end;
    for j := 1 to 3 do begin
      realP[i][j] := inf.readLongint();
    end;
  end;
  
  ja := ans.readLongint();
  pa := ouf.readLongint();
  if (pa < ja) then begin
    quit(_wa, format('Jury has better sum. ja = %d, pa = %d', [ja, pa]));
  end;

  pc := ouf.readLongint();
  if (pc < 0) then begin
    quit(_wa, format('Participant offers to make negative number of examinations: %d', [pc]));
  end;
  if (pc > k) then begin
    quit(_wa, format('Participant offers to make too many examinations: %d, k = %d', [pc, k]));
  end;

  for i := 1 to pc do begin
	examNum := ouf.readLongint();
	if (examNum < 1) or (examNum > n) then begin
	  quit(_pe, format('Bad selectee number on step %d: %d', [i, examNum]));
	end;
	examTypeStr := trim(ouf.readString());  	
	examType := s2n(examTypeStr);
	if (examType = -1) then begin
	  quit(_pe, format('Unknown type of examination on step %d: ' + examTypeStr, [i]));
	end;
	fakeP[examNum][examType] := realP[examNum][examType];
  end;

  prev := -1;
  realPA := 0;
  for i := 1 to m do
  begin
	takeNum := ouf.readLongint();
	if (takeNum < 1) or (takeNum > n) then begin
	  quit(_pe, format('Bad selectee number to be taken: %d', [takeNum]));
	end;
	if (takeNum <= prev) then begin
	  quit(_wa, format('Not increasing order in position %d: %d %d', [i, prev, takeNum]));
	end;
    for j := 1 to 3 do begin
      realPA := realPA + fakeP[takeNum][j];
    end;  
	prev := takeNum;
  end;

  if (realPA <> pa) then begin
    quit(_wa, format('Participant sum does not match the sequence described: real sum is %d, but %d promised', [realPA, pa]));
  end;

  if (pa > ja) then begin
    quit(_fail, format('Participant has better answer than jury has: pa = %d, ja = %d', [pa, ja]));
  end;

  quit(_ok, format('Best sum is %d, %d selectees taken, %d examinations made', [pa, m, pc]));

end.