from collections import defaultdict

N = int(input())
SP = sorted([list(input().split()) + [i + 1] for i in range(N)])

d = defaultdict(list)

for s, p, i in SP:
    d[s].append((int(p), i))

ans = []

for k, v in d.items():
    v = sorted(v)[::-1]
    for i, j in v:
        ans.append(str(j))

print('\n'.join(ans)) from collections import defaultdict N = int(input()) N int(input()) int input() input list(input().split()) + [i + 1] for i in range(N) for i in range(N) i range(N) range N for i in range(N) list(input().split()) + [i + 1] list(input().split()) list input().split() ().split () input split [i + 1] i + 1 i 1 SP = sorted([list(input().split()) + [i + 1] for i in range(N)]) SP sorted([list(input().split()) + [i + 1] for i in range(N)]) sorted [list(input().split()) + [i + 1] for i in range(N)] d = defaultdict(list) d defaultdict(list) defaultdict list for s, p, i in SP:
    d[s].append((int(p), i)) s p i SP d[s].append((int(p), i)) [s].append [s] d s append (int(p), i) int(p) int p i ans = [] ans [] for k, v in d.items():
    v = sorted(v)[::-1]
    for i, j in v:
        ans.append(str(j)) k v d.items() d.items d items v = sorted(v)[::-1] v sorted(v)[::-1] (v) sorted v ::-1 -1 for i, j in v:
        ans.append(str(j)) i j v ans.append(str(j)) ans.append ans append str(j) str j print('\n'.join(ans)) print '\n'.join(ans) '\n'.join '\n' join ans ans = [] [] ans N = int(input()) int(input()) N SP = sorted([list(input().split()) + [i + 1] for i in range(N)]) sorted([list(input().split()) + [i + 1] for i in range(N)]) SP d = defaultdict(list) defaultdict(list) d v = sorted(v)[::-1] sorted(v)[::-1] v
from collections import defaultdict

N = int(input())
SP = sorted([list(input().split()) + [i + 1] for i in range(N)])

d = defaultdict(list)

for s, p, i in SP:
    d[s].append((int(p), i))

ans = []

for k, v in d.items():
    v = sorted(v)[::-1]
    for i, j in v:
        ans.append(str(j))

print('\n'.join(ans))
