n,sc,bp,lv,jjmax,i,j,jj,code,k:integer;
jjmaxx:longint;
na,s,st:string;
gb,xb:char;
begin
readln(n);
j:=0;
for i:=1 to n do
begin
readln(st);
j:=0;
while st[j]<>' ' do inc(j);
na:=copy(st,1,j-1); inc(j); k:=j;
while st[k]<>' ' do inc(k);
val(copy(st,j,k-j),sc,code); inc(k); j:=k;
while st[j]<>' ' do inc(j);
val(copy(st,k,j-k),bp,code); inc(j); k:=j;
while st[k]<>' ' do inc(k);
gb:=st[j]; inc(k); j:=k;
while st[j]<>' ' do inc(j);
xb:=st[k]; inc(j); k:=j;
while k<>length(st) do inc(k);
val(copy(st,j,k-j+1),lv,code);
jj:=0;
if (sc>80)and(lv>=1) then jj:=jj+8000;
if (sc>85)and(bp>80) then jj:=jj+4000;
if (sc>90) then jj:=jj+2000;
if (sc>85)and(xb='Y') then jj:=jj+1000;
if (bp>80)and(gb='Y') then jj:=jj+850;
if jj>jjmax then begin
s:=na;
jjmax:=jj;
end;
jjmaxx:=jjmaxx+jj;
end;
writeln(s);
writeln(jjmax);
writeln(jjmaxx);
end.