Award Ceremony

Description

As you may already know, every team at a programming competition is given a score based on their performance. 1st place is awarded to the team with highest score; 2nd place is awarded to the team with 2nd highest score, and so on. Unfortunately, 6 Ponds HS forgot to sort the contestants by score, and they now need your help.

Input

The first line contains a single integer TT, the number of test cases. TT test cases follow. Each test case begins with an integer NN, the number of contestants. The next NN lines each contain a contestant's name followed by their non-negative integer score. You may assume that names are composed of only alphabetic characters and are unique within a test case. If there is a tie, put the contestant with the alphabetically first name before the other.

Output

For each test case, output the order the contestants in the test case placed, with each contestant's name printed on a separate line. Print a blank line after each test case.

Sample Input

2
6
NotAaron 232
AlsoNotAaron 824
Aaron 1056
OnceAgainNotAaron 232
NotAaronAgain 232
Puya 1440
2
PossiblyYou 733
PossiblyYourOpponents 732

Sample Output

Puya
Aaron
AlsoNotAaron
NotAaron
NotAaronAgain
OnceAgainNotAaron

PossiblyYou
PossiblyYourOpponents

results matching ""

    No results matching ""