#include<iostream> #include<algorithm> using namespace std; struct Student{ int no; int score; }; bool compared(Student std1,Student std2){ if(std1.score==std2.score) return std1.no<std2.no; return std1.score<std2.score; }; int main(){ Student student[100]; int N; cin>>N; for(int i=0;i<N;i++){ cin>>student[i].no>>student[i].score; }; sort(student,student+N,compared); for(int i=0;i<N;i++){ cout<<student[i].no<<' '<<student[i].score<<endl; } }