# coding: utf-8

N = int(input())
D = []
for i in range(N):
    s, p = map(str,input().split())
    p = int(p)
    shop = [s, p, i+1]
    D.append(shop)

D.sort(key=lambda x:x[0])
#print(D[0])
#print(D[1])
T_ = [D[0]]
flg = True
A = []
for i in range(N-1):
    #print(T_)
    if D[i][0] == D[i+1][0]:
        T_.append(D[i+1])
    else:
        T_.sort(key=lambda x:x[1], reverse=True)
        A = A + T_
        T_ = [D[i+1]]
        flg = False
        #print('hoge')

if len(T_) > 0:
    T_.sort(key=lambda x:x[1], reverse=True)
    A = A + T_
#print(A)
for l in A:
    print(l[2]) N = int(input()) N int(input()) int input() input D = [] D [] for i in range(N):
    s, p = map(str,input().split())
    p = int(p)
    shop = [s, p, i+1]
    D.append(shop) 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 shop = [s, p, i+1] shop [s, p, i+1] s p i+1 i 1 D.append(shop) D.append D append shop D.sort(key=lambda x:x[0]) D.sort D sort key=lambda x:x[0] key lambda x:x[0] x[0] x 0 x T_ = [D[0]] T_ [D[0]] D[0] D 0 flg = True flg True A = [] A [] for i in range(N-1):
    #print(T_)
    if D[i][0] == D[i+1][0]:
        T_.append(D[i+1])
    else:
        T_.sort(key=lambda x:x[1], reverse=True)
        A = A + T_
        T_ = [D[i+1]]
        flg = False
        #print('hoge') i range(N-1) range N-1 N 1 if D[i][0] == D[i+1][0]:
        T_.append(D[i+1])
    else:
        T_.sort(key=lambda x:x[1], reverse=True)
        A = A + T_
        T_ = [D[i+1]]
        flg = False
        #print('hoge') D[i][0] == D[i+1][0] D[i][0] [i] D i 0 D[i+1][0] [i+1] D i+1 i 1 0 T_.append(D[i+1]) T_.append T_ append D[i+1] D i+1 i 1 T_.sort(key=lambda x:x[1], reverse=True) T_.sort T_ sort key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True A = A + T_ A A + T_ A T_ T_ = [D[i+1]] T_ [D[i+1]] D[i+1] D i+1 i 1 flg = False flg False if len(T_) > 0:
    T_.sort(key=lambda x:x[1], reverse=True)
    A = A + T_
#print(A) len(T_) > 0 len(T_) len T_ 0 T_.sort(key=lambda x:x[1], reverse=True) T_.sort T_ sort key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True A = A + T_ A A + T_ A T_ for l in A:
    print(l[2]) l A print(l[2]) print l[2] l 2 A = A + T_ A + T_ A shop = [s, p, i+1] [s, p, i+1] shop A = A + T_ A + T_ A T_ = [D[i+1]] [D[i+1]] T_ p = map(str,input().split()) map(str,input().split()) p N = int(input()) int(input()) N flg = False False flg flg = True True flg D = [] [] D T_ = [D[0]] [D[0]] T_ p = int(p) int(p) p s, p = map(str,input().split()) map(str,input().split()) s A = [] [] A
# coding: utf-8

N = int(input())
D = []
for i in range(N):
    s, p = map(str,input().split())
    p = int(p)
    shop = [s, p, i+1]
    D.append(shop)

D.sort(key=lambda x:x[0])
#print(D[0])
#print(D[1])
T_ = [D[0]]
flg = True
A = []
for i in range(N-1):
    #print(T_)
    if D[i][0] == D[i+1][0]:
        T_.append(D[i+1])
    else:
        T_.sort(key=lambda x:x[1], reverse=True)
        A = A + T_
        T_ = [D[i+1]]
        flg = False
        #print('hoge')

if len(T_) > 0:
    T_.sort(key=lambda x:x[1], reverse=True)
    A = A + T_
#print(A)
for l in A:
    print(l[2])