#t270. 病人排队
病人排队
Patient Queue
Problem Background
Special for beginners, ^_^
Problem Description
Patients register to see a doctor. Write a program to arrange the patients into a consultation order according to the following principles:
-
Elderly people (age ) are seen before non-elderly people.
-
Among the elderly, sort by age from oldest to youngest; if ages are equal, sort by registration order.
-
Non-elderly people are seen in registration order.
Input Format
The first line contains a positive integer less than , the number of patients.
Then, in registration order, each line gives one patient's information: a string of length less than representing the patient's ID (each ID is unique and contains only digits and letters), and an integer representing the patient's age, separated by a single space.
Output Format
Output the patients' IDs in the arranged consultation order, one per line.
Sample Input
5
021075 40
004003 15
010158 67
021033 75
102012 30
Sample Output
021033
010158
021075
004003
102012
Constraints
1s, 1024KiB for each test case.