var mz,mz1:string;
n,i,qm,bj,lw,max,jxj:integer;
he:longint;
gb,xb:boolean;
c:char;
begin
assign(input,'scholar.in');reset(input);
assign(output,'scholar.out');rewrite(output);
readln(n);
he:=0;
max:=0;
for i:=1 to n do
begin
jxj:=0;
read(c);
mz:='';
while c<>' ' do
begin
mz:=mz+c;
read(c);
end;
read(qm,bj);
if (qm>85) and (bj>80) then jxj:=jxj+4000;
if qm>90 then jxj:=jxj+2000;
read(c);
read(c);
if c='Y' then gb:=true
else gb:=false;
if (bj>80) and gb then jxj:=jxj+850;
read(c);
read(c);
if c='Y' then xb:=true
else xb:=false;
if (qm>85) and xb then jxj:=jxj+1000;
readln(lw);
if (qm>80) and (lw>0) then jxj:=jxj+8000;
he:=he+jxj;
if jxj>max then
begin
mz1:=mz;
max:=jxj;
end;
end;
writeln(mz1);
writeln(max);
writeln(he);
close(input);close(output);
end.