import sys

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

read = sys.stdin.buffer.read

sys.setrecursionlimit(10 ** 7)

INF = float('inf')



N = int(eval(input()))



import collections

d = collections.defaultdict(list)



for i in range(N):

    S, P = input().split()

    P = int(P)

    d[S].append((i+1, P))



ordered = list(d.keys())

ordered.sort()



for city in ordered:

    mises = d[city]

    mises = sorted(mises, key=lambda x: x[1], reverse=True)

    for mise in mises:

        print((mise[0]))
import sys

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines

read = sys.stdin.buffer.read

sys.setrecursionlimit(10 ** 7)

INF = float('inf')



N = int(eval(input()))

 

SP = []

for i in range(N):

  s,p = input().split()

  SP.append((s,-int(p),i+1))

  

SP.sort()

 

for s,p,i in SP:

  print(i)
import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10**7)
INF = float("inf")
N = int(eval(input()))
import collections

d = collections.defaultdict(list)
for i in range(N):
    S, P = input().split()
    P = int(P)
    d[S].append((i + 1, P))
ordered = list(d.keys())
ordered.sort()
for city in ordered:
    mises = d[city]
    mises = sorted(mises, key=lambda x: x[1], reverse=True)
    for mise in mises:
        print((mise[0]))

import sys

readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10**7)
INF = float("inf")
N = int(eval(input()))
SP = []
for i in range(N):
    s, p = input().split()
    SP.append((s, -int(p), i + 1))
SP.sort()
for s, p, i in SP:
    print(i)

-import collections - -d = collections.defaultdict(list) +SP = [] -    S, P = input().split() -    P = int(P) -    d[S].append((i + 1, P)) -ordered = list(d.keys()) -ordered.sort() -for city in ordered: -    mises = d[city] -    mises = sorted(mises, key=lambda x: x[1], reverse=True) -    for mise in mises: -        print((mise[0])) +    s, p = input().split() +    SP.append((s, -int(p), i + 1)) +SP.sort() +for s, p, i in SP: +    print(i)