n = int(input())
dic = {}
for i in range(1,n+1):
    s,p = map(str,input().split())
    dic.setdefault(s,[])
    dic[s].append([int(p),i])
#print(dic)
sort_list = sorted(dic)
for key in sort_list:
    sort_item = sorted(dic[key],reverse=True)
    #print(sort_item)
    for i in range(len(sort_item)):
        print(sort_item[i][1]) n = int(input()) n int(input()) int input() input dic = {} dic {} for i in range(1,n+1):
    s,p = map(str,input().split())
    dic.setdefault(s,[])
    dic[s].append([int(p),i])
#print(dic) i range(1,n+1) range 1 n+1 n 1 s,p = map(str,input().split()) s map(str,input().split()) map str input().split() ().split () input split p dic.setdefault(s,[]) dic.setdefault dic setdefault s [] dic[s].append([int(p),i]) [s].append [s] dic s append [int(p),i] int(p) int p i sort_list = sorted(dic) sort_list sorted(dic) sorted dic for key in sort_list:
    sort_item = sorted(dic[key],reverse=True)
    #print(sort_item)
    for i in range(len(sort_item)):
        print(sort_item[i][1]) key sort_list sort_item = sorted(dic[key],reverse=True) sort_item sorted(dic[key],reverse=True) sorted dic[key] dic key reverse=True reverse True for i in range(len(sort_item)):
        print(sort_item[i][1]) i range(len(sort_item)) range len(sort_item) len sort_item print(sort_item[i][1]) print sort_item[i][1] [i] sort_item i 1 p = map(str,input().split()) map(str,input().split()) p dic = {} {} dic sort_item = sorted(dic[key],reverse=True) sorted(dic[key],reverse=True) sort_item sort_list = sorted(dic) sorted(dic) sort_list n = int(input()) int(input()) n s,p = map(str,input().split()) map(str,input().split()) s
n = int(input())
dic = {}
for i in range(1,n+1):
    s,p = map(str,input().split())
    dic.setdefault(s,[])
    dic[s].append([int(p),i])
#print(dic)
sort_list = sorted(dic)
for key in sort_list:
    sort_item = sorted(dic[key],reverse=True)
    #print(sort_item)
    for i in range(len(sort_item)):
        print(sort_item[i][1])
