type hehe=record
mingzi:string;
qimo:integer;
banji:integer;
ganbu:boolean;
xibu:boolean;
lunwen:integer;
total:integer
end;
var a:array[1..100] of hehe;
i,n,kong,lala:integer; st:string; m:integer; xuesheng:integer; s:longint;
begin
readln(n);
for i:=1 to n do
with a[i] do begin
readln(st);
kong:=pos(' ',st);
mingzi:=copy(st,1,kong-1);
delete(st,1,kong);
kong:=pos(' ',st);
val(copy(st,1,kong-1),qimo,lala);
delete(st,1,kong);
kong:=pos(' ',st);
val(copy(st,1,kong-1),banji,lala);
delete(st,1,kong);
kong:=pos(' ',st);
if st[kong-1]='Y' then ganbu:=true else ganbu:=false;
delete(st,1,kong);
if st[kong-1]='Y' then xibu:=true else xibu:=false;
delete(st,1,kong);
val(st,lunwen,lala);
if (qimo>80) and (lunwen>=1) then total:=total+8000;
if (qimo>85) and (banji>80) then total:=total+4000;
if qimo>90 then total:=total+2000;
if (qimo>85) and (xibu=true) then total:=total+1000;
if (banji>80) and (ganbu=true) then total:=total+850;
end;
m:=0; xuesheng:=1; s:=0;
for i:=1 to n do
if a[i].total>m then
begin
m:=a[i].total; xuesheng:=i;
end;
for i:=1 to n do
s:=s+a[i].total;
writeln(a[xuesheng].mingzi);
writeln(m);
writeln(s);
readln;
readln;
end.
end;
end.