N=int(eval(input()))

rest_list = []

for i in range(N):

  Si, Pi = input().split()

  Pi = int(Pi)

  rest_list.append((i+1,Si,Pi))

  

for i in range(N-1):

  for j in range(i+1,N):

    ii,Si,Pi = rest_list[i]

    jj,Sj,Pj = rest_list[j]

    

    if Si > Sj or (Si == Sj and Pi < Pj):

      rest_list[i], rest_list[j] = (jj,Sj,Pj),(ii,Si,Pi)

      

for i in range(N):

  i,Si,Pi = rest_list[i]  

  print(i)

      
N=int(eval(input()))

rest_list=[]

for i in range(N):

  S,P=input().split()

  rest_list.append((S,-int(P),i+1))

rest_list.sort()



for s,p,i in rest_list:

  print(i)
N = int(eval(input()))
rest_list = []
for i in range(N):
    Si, Pi = input().split()
    Pi = int(Pi)
    rest_list.append((i + 1, Si, Pi))
for i in range(N - 1):
    for j in range(i + 1, N):
        ii, Si, Pi = rest_list[i]
        jj, Sj, Pj = rest_list[j]
        if Si > Sj or (Si == Sj and Pi < Pj):
            rest_list[i], rest_list[j] = (jj, Sj, Pj), (ii, Si, Pi)
for i in range(N):
    i, Si, Pi = rest_list[i]
    print(i)

N = int(eval(input()))
rest_list = []
for i in range(N):
    S, P = input().split()
    rest_list.append((S, -int(P), i + 1))
rest_list.sort()
for s, p, i in rest_list:
    print(i)

-    Si, Pi = input().split() -    Pi = int(Pi) -    rest_list.append((i + 1, Si, Pi)) -for i in range(N - 1): -    for j in range(i + 1, N): -        ii, Si, Pi = rest_list[i] -        jj, Sj, Pj = rest_list[j] -        if Si > Sj or (Si == Sj and Pi < Pj): -            rest_list[i], rest_list[j] = (jj, Sj, Pj), (ii, Si, Pi) -for i in range(N): -    i, Si, Pi = rest_list[i] +    S, P = input().split() +    rest_list.append((S, -int(P), i + 1)) +rest_list.sort() +for s, p, i in rest_list: