n = int(input())
l = []
for i in range(1,n+1):
    s,p = input().split()
    t = [s,int(p),i]
    l.append(t)
l.sort()
def check(m,i):
    z = list(l[m:i])
    z.sort(key = lambda x: x[1] , reverse = True)
    for j in range(i-m):
        print(z[j][2])
m = 0
for i in range(1,n):
    if l[m][0] != l[i][0]:
        check(m,i)
        m = i
check(m,n) n = int(input()) n int(input()) int input() input l = [] l [] for i in range(1,n+1):
    s,p = input().split()
    t = [s,int(p),i]
    l.append(t) i range(1,n+1) range 1 n+1 n 1 s,p = input().split() s input().split() ().split () input split p t = [s,int(p),i] t [s,int(p),i] s int(p) int p i l.append(t) l.append l append t l.sort() l.sort l sort def check(m,i):
    z = list(l[m:i])
    z.sort(key = lambda x: x[1] , reverse = True)
    for j in range(i-m):
        print(z[j][2]) check z = list(l[m:i]) z list(l[m:i]) list l[m:i] l m:i m i z.sort(key = lambda x: x[1] , reverse = True) z.sort z sort key = lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse = True reverse True for j in range(i-m):
        print(z[j][2]) j range(i-m) range i-m i m print(z[j][2]) print z[j][2] [j] z j 2 m m i i m = 0 m 0 for i in range(1,n):
    if l[m][0] != l[i][0]:
        check(m,i)
        m = i i range(1,n) range 1 n if l[m][0] != l[i][0]:
        check(m,i)
        m = i l[m][0] != l[i][0] l[m][0] [m] l m 0 l[i][0] [i] l i 0 check(m,i) check m i m = i m i check(m,n) check m n p = input().split() input().split() p m = 0 0 m n = int(input()) int(input()) n s,p = input().split() input().split() s m = i i m def check(m,i):
    z = list(l[m:i])
    z.sort(key = lambda x: x[1] , reverse = True)
    for j in range(i-m):
        print(z[j][2]) def check(m,i):
    z = list(l[m:i])
    z.sort(key = lambda x: x[1] , reverse = True)
    for j in range(i-m):
        print(z[j][2]) check t = [s,int(p),i] [s,int(p),i] t l = [] [] l
n = int(input())
l = []
for i in range(1,n+1):
    s,p = input().split()
    t = [s,int(p),i]
    l.append(t)
l.sort()
def check(m,i):
    z = list(l[m:i])
    z.sort(key = lambda x: x[1] , reverse = True)
    for j in range(i-m):
        print(z[j][2])
m = 0
for i in range(1,n):
    if l[m][0] != l[i][0]:
        check(m,i)
        m = i
check(m,n)