type
ar=array[1..200] of longint;
var
n,i,j,k,tot:longint;
name,o:array[1..200] of string;
sc,py,sl,lw,num:ar;
gb,xb:array[1..200] of char;
procedure sort(l,r:longint);
var
i,j,k,m:longint;
k2:string;
begin
i:=l;j:=r;m:=sl[(l+r) div 2];
repeat
while sl[i]>m do inc(i);
while sl[j]<m do dec(j);
if i<=j then begin
k:=sl[i];sl[i]:=sl[j];sl[j]:=k;
k:=num[i];num[i]:=num[j];num[j]:=k;
k2:=name[i];name[i]:=name[j];name[j]:=k2;
inc(i);dec(j);
end;
until i>j;
if i<r then sort(i,r);
if j>l then sort(l,j);
end;
begin
readln(n);
for i:=1 to n do readln(o[i]);
for i:=1 to n do begin
k:=pos(' ',o[i]);
name[i]:=copy(o[i],1,k-1);
delete(o[i],1,k);
k:=pos(' ',o[i]);
val(copy(o[i],1,k-1),sc[i],j);
delete(o[i],1,k);
val(copy(o[i],1,k-1),py[i],j);
gb[i]:=o[i,k+1];
xb[i]:=o[i,k+3];
delete(o[i],1,k+4);
val(o[i],lw[i],j);
end;
for i:=1 to n do num[i]:=i;
fillchar(sl,sizeof(sl),0);
for i:=1 to n do begin
if (sc[i]>80) and (lw[i]>=1) then sl[i]:=sl[i]+8000;
if (sc[i]>85) and (py[i]>80) then sl[i]:=sl[i]+4000;
if sc[i]>90 then sl[i]:=sl[i]+2000;
if (sc[i]>85) and (xb[i]='Y') then sl[i]:=sl[i]+1000;
if (py[i]>80) and (gb[i]='Y') then sl[i]:=sl[i]+850;
end;
sort(1,n);
k:=1;
while sl[k]=sl[k+1] do inc(k);
j:=maxlongint;
for i:=1 to k do
if num[i]<j then j:=i;
tot:=0;
for i:=1 to n do
tot:=tot+sl[i];
writeln(name[j]);
writeln(sl[j]);
writeln(tot);
end.