#include <bits/stdc++.h>
using namespace std ;
struct student
{
string name ;
int qm_cj , bj_cj , lw ;
char gb , west ;
long all = 0 ;
} s [105] , MAX;
int main ()
{
int n , sum = 0 ;
cin >> n ;
for ( int i = 0 ; i < n ; i ++ )
{
cin >> s[i].name >> s[i].qm_cj >> s[i].bj_cj >> s[i].gb >> s[i].west >> s[i].lw ;
if ( s[i].qm_cj > 80 && s[i].lw >= 1 )
{
s[i].all += 8000 ;
}
if ( s[i].qm_cj > 85 && s[i].bj_cj > 80 )
{
s[i].all += 4000 ;
}
if ( s[i].qm_cj > 90 )
{
s[i].all += 2000 ;
}
if ( s[i].west == 'Y' )
{
s[i].all += 1000 ;
}
if ( s[i].bj_cj > 80 && s[i].gb == 'Y' )
{
s[i].all += 850 ;
}
if ( s [i].all > MAX.all )
{
MAX = s[i] ;
}
sum += s[i].all ;
}
cout << MAX.name << endl << MAX.all << endl << sum ;
return 0 ;
}