type
re=record
name:string[20];
score1:integer;
score2:integer;
gan:string;
west:string;
lun:integer;
end;
var
m,i,n,c,d:integer;
e:longint;
a:array[1..100] of re;
b:array [1..100] of integer;
begin
readln(n);
for i:=1 to n do
begin
read(a[i].name);
read(a[i].score1);
read(a[i].score2);
read(a[i].gan);
read(a[i].west);
read(a[i].lun);
end;
for i:=1 to n do
begin
m:=0;
if (a[i].score1>80) and (a[i].lun>=1) then m:=m+8000;
if (a[i].score1>85) and (a[i].score2>80) then m:=m+4000;
if (a[i].score1>90) then m:=m+2000;
if (a[i].score1>85) and (a[i].west='Y') then m:=m+1000;
if (a[i].score2>80) and (a[i].gan='Y') then m:=m+850;
b[i]:=m;
end;
c:=b[1];
for i:= 2 to n do
begin
if b[i]>c then
begin
c:=b[i];
d:=i;
end;
end;
for i:=1 to n do
e:=e+b[i];
writeln(a[i].name);
writeln(c);
writeln(e);
end.