var
a:array[1..1000]of string;
b:array[1..1000]of integer;
i,j,n:integer;
all:longint;
begin
assign(input,'scholar.in');reset(input);
assign(output,'scholar.out');rewrite(output);
readln(n);
all:=0;
for i:=1 to n do b[i]:=0;
for i:=1 to n do readln(a[i]);
for i:=1 to n do
begin
for j:=1 to length(a[i]) do
begin
if ord(a[i][j])=32 then
begin
if ((ord(a[i][j+1])-48)*10+(ord(a[i][j+2])-48))>80 then//期末成绩大于80
begin
if (ord(a[i][j+11]))>48 then b[i]:=b[i]+8000;//院士奖学金
if ((ord(a[i][j+1])-48)*10+(ord(a[i][j+2])-48))>85 then//期末成绩大于85
begin
if ((ord(a[i][j+4])-48)*10+(ord(a[i][j+5])-48))>80 then//班级评议高于80
begin
b[i]:=b[i]+4000;//五四奖学金
if a[i][j+7]='Y' then b[i]:=b[i]+850;//学生贡献奖
end;
if ((ord(a[i][j+1])-48)*10+(ord(a[i][j+2])-48))>90 then b[i]:=b[i]+2000;//成绩优秀奖
if a[i][j+9]='Y' then b[i]:=b[i]+1000;//西部奖学金
end;
end;
break;
end;
end;
end;
for i:=1 to n do
if b[i]>all then
begin
j:=i;
all:=b[i];
end;
all:=0;
for i:=1 to n do
all:=all+b[i];
for i:=1 to 15 do
if a[j][i]<>' ' then write(a[j][i])
else
begin
writeln;
break;
end;
writeln(b[j]);
writeln(all);
//for i:=1 to n do writeln(b[i]);
close(input);close(output);
end.