#include<iostream> #include<cstdio> #include<algorithm> using namespace std; struct Student{ int number; int score; }; bool Compare(Student a,Student b){ if(a.score==b.score){ return a.number<b.number; } else{ return a.score<b.score; } } int main() { int n; scanf("%d\n",&n); Student array[100]; for(int i=0;i<n;++i){ scanf("%d %d\n",&array[i].number,&array[i].score); } sort(array,array+n,Compare); for(int i=0;i<n;++i){ cout<<array[i].number<<" "<<array[i].score<<endl; } return 0; }