var
n,i,g,h,m,l:longint;a,b,c:array[1..100]of integer;
d,e:array[1..100]of char;x:array[1..100]of string;
f:array[1..100]of longint;
begin
assign(input,'scholar.in');
assign(output,'scholar.out');
reset(input);rewrite(output);
readln(n);
for l:=1 to n do begin
readln(x[l]);
h:=0;for i:=1 to length(x[l]) do begin
if x[l][i]=' ' then h:=h+1;
if h=2 then begin a[l]:=ord(x[l][i-1])-ord('0');
if (x[l][i-2]>='0')and(x[l][i-2]<='9')then a[l]:=a[l]+10*(ord(x[l][i-2])-ord('0'));
if (x[l][i-3]>='0')and(x[l][i-3]<='9')then a[l]:=a[l]+100*(ord(x[l][i-3])-ord('0'));h:=h+1;end;end;
h:=0;for i:=1 to length(x[l]) do begin
if x[l][i]=' ' then h:=h+1;
if h=3 then begin b[l]:=ord(x[l][i-1])-ord('0');
if (x[l][i-2]>='0')and(x[l][i-2]<='9')then b[l]:=b[l]+10*(ord(x[l][i-2])-ord('0')); if (x[l][i-3]>='0')and(x[l][i-3]<='9')then b[l]:=b[l]+100*(ord(x[l][i-3])-ord('0'));h:=h+1;end;end;
h:=0;for i:=1 to length(x[l]) do begin
if x[l][i]=' ' then h:=h+1;
if h=4 then begin d[l]:=x[l][i-1];h:=h+1;end;end;
h:=0;for i:=1 to length(x[l]) do begin
if x[l][i]=' ' then h:=h+1;
if h=5 then begin e[l]:=x[l][i-1];c[l]:=ord(x[l][i+1])-ord('0');h:=h+1;end;end;
if (a[l]>80)and(c[l]>0) then f[l]:=f[l]+8000;
if (a[l]>85)and(b[l]>80) then f[l]:=f[l]+4000;
if (a[l]>90) then f[l]:=f[l]+2000;
if (a[l]>85)and(e[l]='Y') then f[l]:=f[l]+1000;
if (b[l]>80)and(d[l]='Y') then f[l]:=f[l]+850;
if f[l]>g then g:=f[l];m:=f[l]+m;end;
for l:=1 to n do
if g=f[l] then begin
for i:=1 to length(x[l]) do if x[l][i]<>' ' then
write(x[l][i]) else break;writeln;
writeln(f[l]);break;end;
write(m);close(input);close(output);end.