#include <bits/stdc++.h>
using namespace std;
struct Record {
int id;
string name;
// 每個學生有五個成績
vector <int> score = vector <int>(5);
int totalScore = 0;
};
bool compare (const Record &a, const Record &b) {
if (a.totalScore != b.totalScore) {
// 分數由高到低
return a.totalScore > b.totalScore;
}
// 總分相同照座號排
return a.id < b.id;
}
int main() {
int n;
cin >> n;
vector <Record> student(n);
for (int i = 0; i < n; i++) {
cin >> student[i].id;
cin >> student[i].name;
// 依序填入學生成績
for (int j = 0; j < 5; j++) {
cin >> student[i].score[j];
// 計算成績總分
student[i].totalScore += student[i].score[j];
}
}
// 排序分數
sort(student.begin(), student.end(), compare);
// 計算名次
vector <int> rank(n);
for (int i = 0; i < n; i++) {
// 如果總分不相同,則名次為前一個+1
if (i == 0 || student[i].totalScore != student[i - 1].totalScore) {
rank[i] = i + 1;
}
// 若總分相同,則名次與前個相同
else {
rank[i] = rank[i - 1];
}
}
// 結果輸出
for (int i = 0; i < n; i++) {
cout << student[i].id << " " << student[i].name << " ";
for (int j = 0; j < 5; j++) {
cout << student[i].score[j] << " ";
}
cout << student[i].totalScore << " " << rank[i] << endl;
}
return 0;
}