nam:string;
qm:1..100;
py:1..100;
gb:string;
xb:string;
lw:0..10;
end;
var stu:array[1..100] of student;
n,i,hao:integer;
m:array[1..100] of integer;
sum,max:longint;
begin
readln(n);
for i:=1 to n do
begin
readln(stu[i].nam,stu[i].qm,stu[i].py,stu[i].gb,stu[i].xb,stu[i].lw);
end;
end.
begin
fillchar(m,sizeof(m),0);
for i:=1 to n do
begin
if (stu[i].qm>80) and (stu[i].lw>=1) then m[i]:=m[i]+8000;
if (stu[i].qm>85) and (stu[i].py>80) then m[i]:=m[i]+4000;
if (stu[i].qm>90) then m[i]:=m[i]+2000;
if (stu[i].qm>85) and (stu[i].xb='Y') then m[i]:=m[i]+1000;
if (stu[i].py>80) and (stu[i].gb='Y') then m[i]:=m[i]+850;
end;
end.
begin
sum:=0;
max:=0;
for i:=1 to n do
begin
sum:=sum+m[i];
end;
for i:=1 to n do
if m[i]>max then max:=m[i]; hao:=i;
writeln(stu[hao].nam);
writeln(m[hao]);
writeln(sum);
end.