import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
List
Scanner sc=new Scanner (System.in) ;
int x=sc.nextInt();
for(int i=0;i<x;i++){
list.add(new PersonSortable(sc.next(),sc.nextInt())) ;
}
Collections.sort(list);
for(PersonSortable e:list){
S
}
}
public class PersonSortable implements Comparable
@Override
public String toString() {
return name+'-'+age;
}
private String name;
private int age;
public PersonSortable(String name,int age){
this.name=name;
this.age=age;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public int compareTo(PersonSortable o){
int x=this.name.compareTo(o.name);
if(x!=0) return x;
else return this.getAge()-o.getAge();
}
}