Var
N,i,j,num,max:longint;
name:array[1..100] of string;
final,class,article,scholar:array[1..100] of longint;
ganbu,xibu:array[1..100] of char;
ch:char;
Begin
Assign(input,'scholar.in');Reset(input);
Assign(output,'scholar.out');Rewrite(output);
Readln(N);
For i:=1 to N do begin
Read(ch);
While ch<>' ' do
begin
name[i]:=name[i]+ch;
read(ch);
end;
Readln(final[i],class[i],ganbu[i],xibu[i],article[i]);
end;
For i:=1 to N do
begin
If (final[i]>80)and(article[i]>=1) then inc(scholar[i],8000);
If (final[i]>85)and(class[i]>80) then inc(scholar[i],4000);
If final[i]>90 then inc(scholar[i],2000);
If (final[i]>85)and(xibu[i]='Y') then inc(scholar[i],1000);
If (class[i]>80)and(ganbu[i]='Y') then inc(scholar[i],850);
end;
num:=0;j:=0;max:=0;
For i:=1 to N do begin
num:=num+scholar[i];
If scholar[i]>max then begin j:=i;max:=scholar[i];end;
end;
Writeln(name[j]);
Writeln(max);
Writeln(num);
Close(input);
Close(output);
End.