import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt(), arr[] = new int[n];
String s[][] = new String[n][2];
for (int i = 0; i < n; i++) {
s[i][0] = scn.next();
int tal = scn.nextInt(), tot = 1000, num = 0;//讀入身高
if (tal > 170)//若大於170加成
tot += (tal - 170) * 100;
else
tot -= (170 - tal) * 100;
for (int j = 0; j < 5; j++) {
num += scn.nextInt(); //讀取智力、耐力、力量、敏捷與精神加入num
}
tot += num * 20;//(智力、耐力、力量、敏捷與精神)*20
arr[i] = tot;//總分數(放入int型態陣列排序用)
s[i][1] = String.valueOf(tot); //s[i][0]存名字 s[i][1]存分數
}
Arrays.sort(arr);
for (int i = n - 1; i >= 0; i--) {//s[i][1]跟排序好的arr[i]做比對依序輸出
for (int j = 0; j < s.length; j++) {
if (Integer.parseInt(s[j][1]) == arr[i]) {
System.out.println(s[j][0]);
}
}
}
}
/* 題目:[C_SO22-易] 你們很強!
作者:1010
時間:西元 2016 年 7 月 */
}