#include <bits/stdc++.h>
using namespace std;
short n;
int ans = 0;
char eastst, Sc;
short classpr, lastpr, luwen;
struct Student {
string name;
int manei;
} STsz[100];
int main() {
cin >> n;
n--;
for (int i = 0; i <= n; i++) {
cin >> STsz[i].name >> lastpr >> classpr >> Sc >> eastst >> luwen;
if (lastpr > 80 && luwen >= 1) {
STsz[i].manei += 8000;
ans += 8000;
}
if (lastpr > 85 && classpr > 80) {
STsz[i].manei += 4000;
ans += 4000;
}
if (lastpr > 90) {
STsz[i].manei += 2000;
ans += 2000;
}
if (eastst == 'Y' && lastpr > 85) {
STsz[i].manei += 1000;
ans += 1000;
}
if (classpr > 80 && Sc == 'Y') {
STsz[i].manei += 850;
ans += 850;
}
if (STsz[i].manei > STsz[i - 1].manei) {
swap(STsz[i], STsz[i - 1]);
}
}
cout << STsz[0].name << endl;
cout << STsz[0].manei << endl;
cout << ans;
return 0;
}