n = int(input())

spl = {}
spl = []
for i in range(n):
    s,p = map(str, input().split())
    p = int(p)
    spl.append((s,p*(-1),i+1))
    # spl.setdefault(s,[])
    # spl[s].append((p,i+1))

spl.sort()
for s,p,i in spl:
    print(i)

# spl = sorted(spl.items(), key=lambda x:x[0])
# for s, pil in spl:
#     pil.sort()
#     for p,i in pil:
#         print(i)

  n = int(input()) n int(input()) int input() input spl = {} spl {} spl = [] spl [] for i in range(n):
    s,p = map(str, input().split())
    p = int(p)
    spl.append((s,p*(-1),i+1))
    # spl.setdefault(s,[])
    # spl[s].append((p,i+1)) i range(n) range n s,p = map(str, input().split()) s map(str, input().split()) map str input().split() ().split () input split p p = int(p) p int(p) int p spl.append((s,p*(-1),i+1)) spl.append spl append (s,p*(-1),i+1) s p*(-1) p -1 i+1 i 1 spl.sort() spl.sort spl sort for s,p,i in spl:
    print(i)

# spl = sorted(spl.items(), key=lambda x:x[0])
# for s, pil in spl:
#     pil.sort()
#     for p,i in pil:
#         print(i)

  s p i spl print(i) print i n = int(input()) int(input()) n p = int(p) int(p) p s,p = map(str, input().split()) map(str, input().split()) s spl = [] [] spl spl = {} {} spl p = map(str, input().split()) map(str, input().split()) p
n = int(input())

spl = {}
spl = []
for i in range(n):
    s,p = map(str, input().split())
    p = int(p)
    spl.append((s,p*(-1),i+1))
    # spl.setdefault(s,[])
    # spl[s].append((p,i+1))

spl.sort()
for s,p,i in spl:
    print(i)

# spl = sorted(spl.items(), key=lambda x:x[0])
# for s, pil in spl:
#     pil.sort()
#     for p,i in pil:
#         print(i)

 