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

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



N = int(readline())

SP = [(x.split()[0].decode('utf-8'),int(x.split()[1])) for x in readlines()]



SP = sorted((name,-pt,i+1) for i,(name,pt) in enumerate(SP))



answer = '\n'.join(str(x[2]) for x in SP)

print(answer)
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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
SP = [(x.split()[0].decode("utf-8"), int(x.split()[1])) for x in readlines()]
SP = sorted((name, -pt, i + 1) for i, (name, pt) in enumerate(SP))
answer = "\n".join(str(x[2]) for x in SP)
print(answer)

-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 + +read = sys.stdin.buffer.read +readline = sys.stdin.buffer.readline +readlines = sys.stdin.buffer.readlines +N = int(readline()) +SP = [(x.split()[0].decode("utf-8"), int(x.split()[1])) for x in readlines()] +SP = sorted((name, -pt, i + 1) for i, (name, pt) in enumerate(SP)) +answer = "\n".join(str(x[2]) for x in SP) +print(answer)