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