#include<bits/stdc++.h>
using namespace std ;
#define int long long
#define faster() ios::sync_with_stdio(false); cin.tie(nullptr) ; cout.tie(nullptr);
#define endl "\n"
struct SinhVien{
string name ;
string maSV ;
string ten;
string ho ;
string ho2 ;
double gpa ;
};
bool cmp(SinhVien a, SinhVien b){
if(a.gpa == b.gpa){
if(a.name == b.name){
return a.ho < b.ho ;
}
else return a.name < b.name ;
}
else return a.gpa > b.gpa ;
}
void solve(){
int n;
cin >> n;
cin.ignore(); // Thêm dòng này để bỏ qua ký tự newline còn sót trong buffer
vector<SinhVien> a(n);
for(int i = 0 ; i < n ; i++){
getline(cin, a[i].maSV);
getline(cin ,a[i].name);
cin >> a[i].gpa ;
cin.ignore(); // Bỏ qua newline sau khi nhập GPA
string tmp = a[i].name ;
stringstream ss(tmp);
string word = "";
vector<string> v;
while(ss >> word){
v.push_back(word);
}
a[i].ten = v[v.size() - 1];
for(int j = 0 ; j < v.size() - 1 ; j++){
a[i].ho += v[j];
}
}
sort(a.begin(), a.end(), cmp);
for(int i = 0 ; i < n ; i++){
cout << a[i].maSV << " " << a[i].name << " ";
if(ceil(a[i].gpa) == floor(a[i].gpa))
cout << (int) a[i].gpa << endl;
else
cout << a[i].gpa << endl;
}
}
signed main(){
faster();
int test = 1 ;
while(test--){
solve();
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZCA7CiNkZWZpbmUgaW50IGxvbmcgbG9uZyAKI2RlZmluZSBmYXN0ZXIoKSBpb3M6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7IGNpbi50aWUobnVsbHB0cikgOyBjb3V0LnRpZShudWxscHRyKTsKI2RlZmluZSBlbmRsICJcbiIKCnN0cnVjdCBTaW5oVmllbnsKICAgIHN0cmluZyBuYW1lIDsKICAgIHN0cmluZyBtYVNWIDsKICAgIHN0cmluZyB0ZW47CiAgICBzdHJpbmcgaG8gOwogICAgc3RyaW5nIGhvMiA7CiAgICBkb3VibGU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