n = int(input())
spi = []
for i in range(n):
    s,p = input().split()
    spi.append([s,int(p), i+1])
spi.sort()
before = spi[0][0]
ans = [spi[0][2]]
for s,p,i in spi[1:]:
    if s == before:
        ans.append(i)
    else:
        for x in ans[::-1]:
            print(x)
        before = s
        ans = [i]
for x in ans[::-1]:
    print(x) n = int(input()) n int(input()) int input() input spi = [] spi [] for i in range(n):
    s,p = input().split()
    spi.append([s,int(p), i+1]) i range(n) range n s,p = input().split() s input().split() ().split () input split p spi.append([s,int(p), i+1]) spi.append spi append [s,int(p), i+1] s int(p) int p i+1 i 1 spi.sort() spi.sort spi sort before = spi[0][0] before spi[0][0] [0] spi 0 0 ans = [spi[0][2]] ans [spi[0][2]] spi[0][2] [0] spi 0 2 for s,p,i in spi[1:]:
    if s == before:
        ans.append(i)
    else:
        for x in ans[::-1]:
            print(x)
        before = s
        ans = [i] s p i spi[1:] spi 1: 1 if s == before:
        ans.append(i)
    else:
        for x in ans[::-1]:
            print(x)
        before = s
        ans = [i] s == before s before ans.append(i) ans.append ans append i for x in ans[::-1]:
            print(x)
         x ans[::-1] ans ::-1 -1 print(x) print x before = s before s ans = [i] ans [i] i for x in ans[::-1]:
    print(x) x ans[::-1] ans ::-1 -1 print(x) print x before = s s before before = spi[0][0] spi[0][0] before ans = [i] [i] ans p = input().split() input().split() p s,p = input().split() input().split() s n = int(input()) int(input()) n spi = [] [] spi ans = [spi[0][2]] [spi[0][2]] ans
n = int(input())
spi = []
for i in range(n):
    s,p = input().split()
    spi.append([s,int(p), i+1])
spi.sort()
before = spi[0][0]
ans = [spi[0][2]]
for s,p,i in spi[1:]:
    if s == before:
        ans.append(i)
    else:
        for x in ans[::-1]:
            print(x)
        before = s
        ans = [i]
for x in ans[::-1]:
    print(x)