n = int(input())
d = {}
for i in range(1,n+1):
    s, p = input().split()
    if s in d.keys():
        d[s][i] = int(p)
    else:
        d[s] = {i:int(p)}
for k, v in sorted(d.items()):
    for kk, vv in sorted(v.items(), key=lambda x: -x[1]):
        print(kk) n = int(input()) n int(input()) int input() input d = {} d {} for i in range(1,n+1):
    s, p = input().split()
    if s in d.keys():
        d[s][i] = int(p)
    else:
        d[s] = {i:int(p)} i range(1,n+1) range 1 n+1 n 1 s, p = input().split() s input().split() ().split () input split p if s in d.keys():
        d[s][i] = int(p)
    else:
        d[s] = {i:int(p)} s in d.keys() s d.keys() d.keys d keys d[s][i] = int(p) d[s][i] [s] d s i int(p) int p d[s] = {i:int(p)} d[s] d s {i:int(p)} i i int(p) int p for k, v in sorted(d.items()):
    for kk, vv in sorted(v.items(), key=lambda x: -x[1]):
        print(kk) k v sorted(d.items()) sorted d.items() d.items d items for kk, vv in sorted(v.items(), key=lambda x: -x[1]):
        print(kk) kk vv sorted(v.items(), key=lambda x: -x[1]) sorted v.items() v.items v items key=lambda x: -x[1] key lambda x: -x[1] -x[1] x[1] x 1 x print(kk) print kk d = {} {} d s, p = input().split() input().split() s n = int(input()) int(input()) n p = input().split() input().split() p
n = int(input())
d = {}
for i in range(1,n+1):
    s, p = input().split()
    if s in d.keys():
        d[s][i] = int(p)
    else:
        d[s] = {i:int(p)}
for k, v in sorted(d.items()):
    for kk, vv in sorted(v.items(), key=lambda x: -x[1]):
        print(kk)