#include<bits/stdc++.h> using namespace std; struct node{ string name; double score; }a[10005]; bool cmp(s a,s b){ return a.score>b.score; } int main() { int x;{ string name; double score; } cin>>x; for(int i=1;i<=x;i++){ cin>>a[i].name>>a[i].score; } sort(a,a+n,cmp); for(int i=1;i<=x;i++){ cout<<a[i].name<<" "<<a[i].score<<endl; } return 0; }