n = int(input())
info = {}
for i in range(1, n + 1):
    s, p = input().split()
    info[i] = (s, int(p))

ans = list(info.keys())
ans.sort(key=lambda i: info[i][1], reverse=True)
ans.sort(key=lambda i: info[i][0])
for i in ans:
    print(i) n = int(input()) n int(input()) int input() input info = {} info {} for i in range(1, n + 1):
    s, p = input().split()
    info[i] = (s, int(p)) i range(1, n + 1) range 1 n + 1 n 1 s, p = input().split() s input().split() ().split () input split p info[i] = (s, int(p)) info[i] info i (s, int(p)) s int(p) int p ans = list(info.keys()) ans list(info.keys()) list info.keys() info.keys info keys ans.sort(key=lambda i: info[i][1], reverse=True) ans.sort ans sort key=lambda i: info[i][1] key lambda i: info[i][1] info[i][1] [i] info i 1 i reverse=True reverse True ans.sort(key=lambda i: info[i][0]) ans.sort ans sort key=lambda i: info[i][0] key lambda i: info[i][0] info[i][0] [i] info i 0 i for i in ans:
    print(i) i ans print(i) print i p = input().split() input().split() p ans = list(info.keys()) list(info.keys()) ans s, p = input().split() input().split() s info = {} {} info n = int(input()) int(input()) n
n = int(input())
info = {}
for i in range(1, n + 1):
    s, p = input().split()
    info[i] = (s, int(p))

ans = list(info.keys())
ans.sort(key=lambda i: info[i][1], reverse=True)
ans.sort(key=lambda i: info[i][0])
for i in ans:
    print(i)
