import java.util.*;
class student {
String name;
int korScore, mathScore, engScore;
float mean;
int ranking;
student() {
}
student(String name, int korScore, int mathScore, int engScore) {
this.name = name;
this.korScore = korScore;
this.mathScore = mathScore;
this.engScore = engScore;
this.mean = (float)((this.korScore + this.mathScore + this.engScore) / 3.0);
System.out.println(this.mean);
this.ranking=0;
}
}
public class Main {
public static void main(String[] args) {
Scanner t = new Scanner(System.in);
student []x = new student[5];
for(int i=0; i<5; i++) {
String name = t.next();
int kor = t.nextInt();
int math = t.nextInt();
int eng = t.nextInt();
x[i] = new student(name, kor, math, eng);
}
float max = -1;
float min = 2147483647;
String getName = "";
int rank = 0;
for(int i=0; i<x.length; i++) {
if(x[i].mean > max) {
getName = x[i].name;
max = x[i].mean;
}
}
// System.out.println( getName.toString()+"is on the podium");
for(int i=0; i<x.length; i++) {
for(int j=0; j<x.length; j++) {
if(x[i].mean>x[j].mean&&j!=i) {
rank= x[i].ranking;
getName=x[i].name;
}
}
x[i].ranking+=1;
System.out.println(rank);
System.out.println(getName);
}
}
}