program jxj;
var
n:longint;
mz:array[1..150]of string[20];
qm:array[1..150]of longint;
pc:array[1..150]of longint;
gb:array[1..150]of boolean;
xb:array[1..150]of boolean;
lw:array[1..150]of longint;
jj:array[1..150]of longint;
i,j,k,l,s:longint;
h,m:array[1..150]of char;
f,g:array[1..150]of char;
jiede:array[1..50]of char;
begin
readln(n);
for i:=1 to n do
begin
s:=0;
repeat
s:=s+1;
read(jiede[s]);
if jiede[s]<>chr(10) then
mz[i]:=mz[i]+jiede[s];
until jiede[s]=' ';
read(qm[i],pc[i]);
s:=1;
read(f[1]);
repeat
s:=s+1;
read(f[s]);
until f[s]=' ';
s:=1;
read(g[1]);
repeat
s:=s+1;
read(g[s]);
until g[s]=' ';
readln(lw[i]);
for j:=1 to 2 do
if f[j]<>' ' then h[i]:=f[j];
for j:=1 to 2 do
if g[j]<>' ' then m[i]:=g[j];
if h[i]='Y' then gb[i]:=true
else gb[i]:=false;
if m[i]='Y' then xb[i]:=true
else xb[i]:=false;
end;
for i:=1 to n do
begin
if (qm[i]>80)and(lw[i]>=1) then
jj[i]:=jj[i]+8000;
if (qm[i]>85)and(pc[i]>80) then
jj[i]:=jj[i]+4000;
if qm[i]>90 then
jj[i]:=jj[i]+2000;
if (qm[i]>85)and(xb[i]=true) then
jj[i]:=jj[i]+1000;
if (pc[i]>80)and(gb[i]=true) then
jj[i]:=jj[i]+850;
end;
l:=1;
s:=0;
for i:=1 to n do
s:=s+jj[i];
for i:=1 to n do
if jj[l]<jj[i] then l:=i;
writeln(mz[l]);
writeln(jj[l]);
writeln(s);
end.