#include <iostream> #include <algorithm> #include <cmath> using namespace std; typedef struct Student{ int no; int sc; }S; bool cmp(S s1, S s2) { if(s1.sc!=s2.sc)return s1.sc<s2.sc; return s1.no<s2.no; } S s[110]; int main() { int n; cin>>n; for(int i=0;i<n;i++) { cin>>s[i].no>>s[i].sc; } sort(s,s+n,cmp); for(int i=0;i<n;i++)cout<<s[i].no<<" "<<s[i].sc<<endl; } // 64 位输出请用 printf("%lld")