Limits 1s, 512 MB

Sakib likes competitive programming. Often he takes part in online programming contests. But due to his secretive nature, he has multiple accounts in different programming contest platforms. He has so many accounts that it is very difficult to remember all of them and sometimes cannot even remember his own username and gets into trouble.

Codeforces is the most popular platform for competitive programmers. Whenever someone asks Sakib about his CF(Codeforces) handle(username), he gets into trouble because he is confused about which handle he should tell, he has hundreds of them.

After too much effort, he finally listed all of his handles in Codeforces. He also noted down ratings of these accounts. Now, Sakib decided that if someone asks Sakib his CF handle, he will tell him the handle which has the maximum rating.

But there is still a problem, what if there are multiple handles having the maximum rating? Sakib decided that in this case, he would tell the handle which comes first in lexicographical order(dictionary order) based on ASCII values. Can you help Sakib?

Please see the notes below to know about lexicographical order.

Input

First line contains a single integer T (1 ≤ T ≤ 100), which is the number of test cases. Each case starts with a number N (1 ≤ N ≤ 100) in a single line which is the number of CF handles that Sakib has. Then N lines follow, each containing a string S (1 ≤ |S| ≤ 20) and an integer R (-5000 ≤ R ≤ 5000), the handle and the rating of that handle.
A handle S may contain uppercase and lowercase English letters (‘a’ to ‘z’ and ‘A’ to ‘Z’), numbers (‘0’-’9’), underscore (‘_’) and the decimal point (‘.’), There won't be any space inside a single handle. Also there will be no duplicate handles in a test case, all of them will be unique.

Output

For each test case, output the handle Sakib decided to tell if anyone asks him.

Sample

InputOutput
2
5
SAKIB_ALAMIN 1674
sakiib 1529
Dragon_162 1295
SakibAlamin 1240
SakibAlamin2.0 1466
4
SAKIB_ALAMIN 1674
sakiib 1755
Dragon_162 1295
SakibAlamin 1755
SAKIB_ALAMIN
SakibAlamin

In the first case, "SAKIB_ALAMIN" has the maximum rating which is 1674.

In the second case, "sakiib" and "SakibAlamin" both have the maximum rating 1755. But "SakibAlamin" is lexicographically smaller than "sakiib".


NOTE: A string a is lexicographically smaller than a string b if and only if one of the following holds:

  • a is a prefix of b, but a≠b;
  • in the first position where a and b differ, the string a has a letter that appears earlier in the alphabet than the corresponding letter in b. Please note that, capital letters come before lower case letters, "." comes before capital letters, "_" comes after the capital letters but before the lower cases, and digits come after "." but before upper case letters.

Examples:

  1. "aaxbcd" is lexicographically smaller than "xaa"
  2. "A" is lexicographically smaller than "a"
  3. "a.aaa" is lexicographically smaller than "aAaa"
  4. "a.aaa" is lexicographically smaller than "aAaa"
  5. "aAaa" is lexicographically smaller than "a.aaa"
  6. "a_aabcz" is lexicographically smaller than "aaaaa"
  7. "aaA" is lexicographically smaller than "aaa"
  8. "aabx" is lexicographically smaller than "aacx"
  9. "aab" is lexicographically smaller than "aaba"
  10. "aab9" is lexicographically smaller than "aabA"

To know more about Lexicographical_order,
ASCII

Submit

Login to submit.

Statistics

88% Solution Ratio
FairoozREarliest, Jun '20
Moumi_Fastest, 0.0s
FairoozRLightest, 131 kB
bokaifShortest, 155B
Toph uses cookies. By continuing you agree to our Cookie Policy.