b:array[1..1000,1..1000]of longint;
ch,chr:array[1..1000]of char;
str:array[1..1000]of string;
i,j,k,l,s,t:longint;
begin
readln(s);
for i:=1 to s do
read(str[i],a[i,1],a[i,2],ch[i],chr[i],a[i,3]);
for i:=1 to s do
begin
if (a[i,1]>80)and(a[i,3]>=1) then b[i,2]:=b[i,2]+8000;
if (a[i,2]>80)and(a[i,1]>85)then b[i,2]:=b[i,2]+4000;
if a[i,1]>90 then b[i,2]:=b[i,2]+2000;
if (a[i,1]>85)and(chr[i]='y')then b[i,2]:=b[i,2]+1000;
if (a[i,2]>80)and(ch[i]='y') then b[i,2]:=b[i,2]+850;
l:=l+b[i,2];
end;
for i:=1 to s-1 do
for j:=i+1 to s do
if b[i,2]<b[j,2] then
begin
t:=b[i,2];b[i,2]:=b[j,2];b[j,2]:=t;
end;
writeln(str[1],b[i,2],b[i,3]);
end.
var n,i,j,max,people,s:longint;
ch:string;
z:array[1..1000]of string;
a,b,e,f:array[1..100000]of longint;
c,d:array[1..100]of char;
begin
readln(n);
for i:=1 to n do
begin
readln(ch);
ch:=ch+' ';
j:=pos(' ',ch);
z[i]:=Copy(ch,1,j-1);
Delete(ch,1,j);
j:=pos(' ',ch);
val(Copy(ch,1,j-1),a[i]);
Delete(ch,1,j);
j:=pos(' ',ch);
val(Copy(ch,1,j-1),b[i]);
Delete(ch,1,j);
c[i]:=ch[1];
d[i]:=ch[3];
Delete(ch,1,4);
j:=pos(' ',ch);
val(Copy(ch,1,j-1),e[i]);
end;
for i:=1 to n do
begin
if (a[i]>80) and (e[i]>0) then f[i]:=f[i]+8000;
if (a[i]>85) and (b[i]>80) then f[i]:=f[i]+4000;
if a[i]>90 then f[i]:=f[i]+2000;
if (a[i]>85) and (d[i]='Y') then f[i]:=f[i]+1000;
if (b[i]>80)and (c[i]='Y') then f[i]:=f[i]+850;
end;
for i:=1 to n do
begin
if f[i]>max then
begin
max:=f[i];
people:=i;
end;
s:=s+f[i];
end;
writeln(z[people]);
writeln(max);
writeln(s);
end.