#include<bits/stdc++.h>
using namespace std;
struct student{
string c,n;
long long chengji;
}a[1000100];
bool cmp(student a,student b){
return a.c<b.c;
}
int main(){
int ac;
cin>>ac;
for(int i=0;i<ac;++i)cin>>a[i].c>>a[i].n>>a[i].chengji;
sort(a,a+ac,cmp);
for(int i=0;i<ac;++i)cout<<a[i].chengji<<"\n";
return 0;
}