9164 - Stable Sort   

Description

Input

 The input includes multiple test cases. In each test case, the first line contains one integer N. The following N lines specify the name Si and the grade Gi.

1 <= N <= 2*106

1 <= |Si| <= 10

0 <= Gi <= 100 (Gi is an integer.)

Output

  Output the result in N lines. Every line contains the name and the grade. If more people’s grades are same, output by input order. (That means it uses stable sort.)

Sample Input  Download

Sample Output  Download

Tags




Discuss