program p16;
var
n,i:integer;
a,b,e:array [1..100] of integer;
c,d,ch :array [1..100] of char;
x:array [1..100] of string;
maxname: string;
p,total,max:longint;
begin
readln(n);
for i:=1 to n do
begin
read(ch);
while ch<>' ' do
begin
x[i]:=x[i]+ch;
read(ch);
end;
readln(a[i],b[i],ch,c[i],ch,d[i],ch,e[i]);
end;
max:=0;
total:=0;
for i:=1 to n do
begin
p:=0;
if (a[i]>80) and (e[i] >= 1) then inc(p,8000);
if (a[i]>85) and (b[i] > 80) then inc(p,4000);
if a[i]>90 then inc(p,2000);
if (a[i]>85) and (d[i]='Y') then inc(p,1000);
if (b[i]>80) and (c[i]='Y') then inc(p,850);
if p>max then
begin
max:=p;
maxname:=x[i];
end;
total:=total+p;
end;
writeln(maxname);
writeln(max);
write(total);
end.