Problem:
 Score : 200 points    Problem Statement You have decided to write a book introducing good restaurants.
There are N restaurants that you want to introduce: Restaurant 1 , Restaurant 2 , ... , Restaurant N . Restaurant i is in city S_i , and your assessment score of that restaurant on a 100 -point scale is P_i .
No two restaurants have the same score.  You want to introduce the restaurants in the following order:   The restaurants are arranged in lexicographical order of the names of their cities.  If there are multiple restaurants in the same city, they are arranged in descending order of score.   Print the identification numbers of the restaurants in the order they are introduced in the book.      Constraints  1 ≤ N ≤ 100  S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.  0 ≤ P_i ≤ 100  P_i is an integer.  P_i ≠ P_j  (1 ≤ i < j ≤ N)         Input Input is given from Standard Input in the following format:  N  S_1  P_1  :  S_N  P_N       Output Print N lines. The i -th line ( 1 ≤ i ≤ N ) should contain the identification number of the restaurant that is introduced i -th in the book.        Sample Input 1 6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40      Sample Output 1 3
4
6
1
5
2  The lexicographical order of the names of the three cities is kazan  <  khabarovsk  <  moscow . For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2 .       Sample Input 2 10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100      Sample Output 2 10
9
8
7
6
5
4
3
2
1

Solution (Python):
N = int(input())
city = []
point = []
for i in range(N):
    S,P = input().split()
    P = int(P)
    city += [S]
    point += [P]

citys = sorted(city)
i = 0
while i < N:
    how = city.count(citys[i])
    if how == 1:
        print(city.index(citys[i])+1)
        i += 1
    else:
        indexes = [j for j, x in enumerate(city) if x == citys[i]]
        points = sorted([point[j] for j in indexes])[::-1]
        for k in points:
            print(point.index(k)+1)
        i += len(indexes)

Solution (Python):
N = int(input())
SP_ = []
for i in range(N):
  s,p = input().split()
  SP_.append([s,int(p),i])
  
SP_s = sorted(SP_,key=lambda x:(x[0],-x[1]))


for i in range(N):
  print(SP_s[i][2]+1)

Solution (Python):
N = int(input())
X = [[None for i in range(3)] for j in range(N)]
for i in range(N):
    X[i][0] = i+1
    a = input().split()
    X[i][1] = a[0]
    X[i][2] = int(a[1])
X.sort(key=lambda x: (x[1], -x[2]))
for i in range(N):
    print(X[i][0])

Solution (Python):
n = int(input())
l =[]
for i in range(n):
  l.append(list(input().split()))
  l[i][1] = int(l[i][1])
  l[i].append(i+1)
l.sort(key=lambda x:(x[0],-x[1]))

for i in range(n):
  print(l[i][2])

Solution (Python):
n = int(input())

l = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    l.append([s, p, i+1])
    

l = sorted(l, key=lambda x:x[1], reverse=True)

l = sorted(l, key=lambda x:x[0])


for item in l:
    print(item[2])

Solution (Python):
n=int(input())
s=[]

for i in range(n):
  a,b=map(str,input().split())
  b=int(b)
  s.append([a,100-b,i+1])
  
s.sort(key=lambda x:(x[0],x[1]))


for i in range(n):
  print(s[i][2])

Solution (Python):
N=input()

L=[]

for i in range(N):
	s,p=raw_input().split()
	L.append( [s , int(p),i+1] )

L.sort(key=lambda x:(x[0],-x[1]) )

for x,y,z in L:
	print z

Solution (Python):
N = int(input())
S = []
 
for i in range(N):
    ts,tp = input().split()
    ts = str(ts)
    tp = 100-int(tp)
    S.append([ts,tp,i+1])
    
S.sort(key=lambda x:(x[0],x[1]))

for i in range(N):
    print(S[i][2])

Solution (Python):

from operator import itemgetter

x = int(input())


o = []
for i in range(x):
    a, b = input().split()
    o.append([i+1, a, int(b)])
o.sort(key=itemgetter(2), reverse=True)
o.sort(key=itemgetter(1))

for j in range(x):
    print(o[j][0])

Solution (Python):
n = int(input())
sp = [list(map(str,input().split())) for _ in range(n)]

c = 1
for i in sp:
    i[1] = int(i[1])
    i.append(c)
    c += 1

sp = sorted(sp, key=lambda x:x[1] ,reverse=True)
sp = sorted(sp, key=lambda x:x[0])

for i in sp:
    print(i[2])

Solution (Python):
N = int(input())
spList = [input().split() for _ in range(N)]

ispList = []
for i, sp in enumerate(spList):
    ispList.append((i+1, sp[0], int(sp[1])))

ispList.sort(key=lambda x: (x[1], -x[2]))
for i, isp in enumerate(ispList):
    print(isp[0])

Solution (Python):
n = int(input())
x = {}
for i in range(1,n+1):
  si,pi = map(str,input().split())
  if si not in x.keys():
    x[si] = [(int(pi),i)]
  else:
    x[si].append((int(pi),i))
y = sorted(x.keys())
for k in y:
  xk = x[k]
  xk.sort(key=lambda xx:xx[0],reverse=True)
  for i in xk:
    print(i[1])

Solution (Python):
from operator import itemgetter

N = int(input())
SP = []
d = {}
for i in range(1, N+1):
    s, p = input().split()
    SP.append([s, -int(p), i])
    d[int(p)] = i


SP.sort()
[print(i[2]) for i in SP]

Solution (Python):

n = int(input())
res = [[i] + input().split() for i in range(n)]

res.sort(key=lambda x: (x[1], -int(x[2])))

for r in res:
    print(r[0] + 1)

Solution (Python):
n = int(input())  
li = list()

for i in range(n):
    s, p = input().split()
    li.append([s, int(p), i+1])

li.sort()
lastcity = li[0][0]
newli = list()

for i in range(n):
    if lastcity == li[i][0]:
        newli.append([li[i][1], li[i][2]])
        lastcity = li[i][0]
    else:
        newli = newli[::-1]
        for tmp in newli:
            print(tmp[1])
        newli = list()
        newli.append([li[i][1], li[i][2]])
        lastcity = li[i][0]

newli = newli[::-1]
for tmp in newli:
    print(tmp[1])

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    sp = []
    for i in range(n):
        a, b = input().split()
        b = int(b)
        sp.append([a, b, i])
    sp.sort(key=lambda x:(x[0], -x[1]))
    for arr in sp:
        print(arr[2]+1)

Solution (Python):
N = int(input())
R = []
for i in range(N):
    s, p = input().split()
    R.append((s, -int(p), i))

R.sort()
for i in R:
    print(i[2] + 1)

Solution (Python):
n = int(input())
book = {}
for i in range(n):
  tmp = input().split()
  name = tmp[0]
  score = int(tmp[1])
  if name not in book:
    book[name] = {}
    book[name][score] = i + 1
  else:
    book[name][score] = i + 1

for key_city in sorted(book.keys()):
  for key_score in sorted(book[key_city].keys(), key=lambda x: -x):
  	print(book[key_city][key_score])

Solution (Python):
n = int(input())
a = []
for i in range(n):
        s,p = input().split()
        a.append([i+1,s,-int(p)])

for i,_,_2 in sorted(a, key=lambda x:(x[1],x[2])):
        print(i)

Solution (Python):
from collections import defaultdict
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
def ls(): return stdin.readline().split()
N = ii()
city_r = defaultdict(list)
for i in range(1, N + 1):
    c, s = ls()
    s = int(s)
    city_r[c].append( (s, i) )
keys = sorted(city_r.keys())
for k in keys:
    vs = city_r[k]
    vs.sort(key=lambda x:-x[0])
    for v in vs:
        print(v[1])

Solution (Python):
from operator import itemgetter
n = int(input())
p = [list(map(str, input().split())) for i in range(n)]
for i in range(n):
    p[i][1] = int(p[i][1])
    p[i].append(i+1)
pp = sorted(p, key=itemgetter(1), reverse=True)
ppp = sorted(pp, key=itemgetter(0))
for i in range(n):
    print(ppp[i][2])

Solution (Python):
import operator
n = int(input())
s = []
p = []
for i in range(n):
    x, y = input().split()
    s.append((x, int(y), i+1))
s = sorted(s, key=lambda x:(x[0], -x[1]))
for c in s:
    print(c[2])

Solution (Python):
N = int(input())
list = []
for i in range(N):
    S, P = input().split()
    list.append([S, int(P), i+1])

list = sorted(list,key=lambda x:(x[0],-x[1]))

for l in list:
  print(l[2])

Solution (Python):
def main():
    n=int(input())
    s_list=[]
    for i in range(n):
        city,score=input().split(' ')
        s_list.append((score,city,i+1))
    s_list=sorted(s_list,key=lambda s_list: int(s_list[0]),reverse=True)
    s_list=sorted(s_list,key=lambda s_list: s_list[1])
    for i in s_list:
        print(i[2])

if __name__=='__main__':
    main()

Solution (Python):
N = int(input())

SP = {}
for i in range(N):
    s, p = input().split()
    if s in SP.keys():
        SP[s].append([int(p), i])
    else:
        SP[s] = [[int(p), i]]
    
SP = sorted(SP.items(), key=lambda x:x[0], reverse=False)

for sp_set in SP:
    sps = sp_set[1]
    sps.sort(key=lambda x:x[0], reverse=True)
    for item in sps:
        print(item[1]+1)

Solution (Python):

n = int(input())
dic = {}

for i in range(n):
    shop, ten = input().split()
    ten = int(ten)
    if shop in dic:
        dic[shop].append({i+1:ten})
    else:
        dic.update({shop: [{i+1:ten}]})


for k, v in sorted(dic.items()):
    d = {}
    for a in v:
        d.update(a)

    for a, b in sorted(d.items(), key=lambda x: -x[1]):
        print(a)

Solution (Python):
N = int(input())
a = []
for i in range(N):
    b = list(input().split())
    b[1] = int(b[1])
    b.append(i+1)
    a.append(b)
c = sorted(a, key = lambda x:(x[0], -x[1]))
for l in range(N):
    print(c[l][2])

Solution (Python):
l = []
for i in range(int(input())):
  s,p = map(str, input().split())
  l.append((s,100-int(p),i+1))
m = sorted(l)
for i in m:
  print(i[2])

Solution (Python):
n = int(input())

res = []
for i in range(1, n+1):
    si, pi = list(input().split())
    res.append([si, int(pi), i])
    
res.sort(key = lambda x: x[1], reverse=True)

res.sort(key = lambda x: x[0])


for i in range(n):
    print(res[i][2])

Solution (Python):
guideBook = {}
N = int(input())

for index in range(N):
    S, strP = input().split()
    P = int(strP)
    if S in guideBook.keys():
        guideBook[S].setdefault(P,index+1)
    else:
        guideBook.setdefault(S,{P:(index+1)})

citylist = list(guideBook.keys())
citylist.sort()

for city in citylist:
    pointList = list(guideBook[city].keys())
    pointList.sort(reverse=True)
    for point in pointList:
        print(guideBook[city][point])

Solution (Python):
n = int(input())
rest = []
for i in range(n):
    c = input().split()
    a = []
    a.append(c[0])
    b = int(c[1])
    a.append(b)
    a.append(i+1)
    rest.append(a)

rest.sort(key = lambda x: (x[0],-x[1]))
for i in range(len(rest)):
    print(rest[i][2])

Solution (Python):

def comp_rest(a,b):
    if a[0] > b[0]:
        return True
    elif a[0] < b[0]:
        return False
    elif a[0] == b[0]:
        return a[1] < b[1]

def solve():
    N = int(raw_input())
    SP = []
    for i in range(N):
        SiPi = raw_input().split()
        Si = SiPi[0]
        Pi = int(SiPi[1])
        SP.append([Si, Pi, i+1])
    for i in range(N):
        for j in range(i+1, N):
            if comp_rest(SP[i], SP[j]):
                SP[i], SP[j] = SP[j], SP[i]
    for i in range(N):
        print SP[i][2]

if __name__ == '__main__':
    solve()

Solution (Python):

N = int(input())


SP_list=[]

for i in range(N):
  S,P = map(str, input().split())
  SP_list.append([S,int(P),i+1])
  
SP_list.sort(key=lambda x:(x[0],-x[1]))

for i in range(N):
  print(SP_list[i][2])

Solution (Python):
import math
import sys
sys.setrecursionlimit(10 ** 6 + 10)
from collections import defaultdict




def main():
    num = int(input())
    data = [input().split() for i in range(num)]

    for i in range(num):
        data[i][1] = int(data[i][1])
        data[i].append(i + 1)

    data.sort(key=lambda x: (x[0], -x[1]))
    for i in range(num):
        print(data[i][2])




if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
l = []
for i in range(N):
    S, P = input().split()
    P = int(P)
    l.append([i+1, S, -P])
    
l = sorted(l, key=lambda x: (x[1], x[2]))
for i in l:
    print(i[0])

Solution (Python):
n = int(input())
ss = []
for i in range(n):
    s,p = input().split()
    p = int(p)
    ss.append([i+1,s,p])
ss.sort(key=lambda x:x[2], reverse=True)
ss.sort(key=lambda x:x[1])
for i in range(n):
    print(ss[i][0])

Solution (Python):
N = int(input())
X = []
for i in range(N):
	s, p = input().split()
	X.append([s, -int(p),  i+1])
X.sort()
for i in range(N):
	print(X[i][2])

Solution (Python):
n = int(input())
data = []
for i in range(n):
    name, review = input().split()
    data.append([name, int(review), i + 1])
copy = sorted(data, key=lambda x: -x[1])
copy.sort(key=lambda x: x[0])
for p in copy:
    print(p[2])

Solution (Python):
restrunt_num = int(input())

restrunt_list = []
for i in range(1, restrunt_num+1):
    city, point = input().split()
    restrunt_list.append([city, int(point), i])

sorted_list = sorted(restrunt_list, key=lambda x: (x[0], -x[1]))
for r in sorted_list:
    print(r[2])

Solution (Python):
n = int(input())
s, p = [], []
for _ in range(n):
    s_, p_ = input().split()
    s.append(s_)
    p.append(100 - int(p_))

max_len = max([len(e) for e in s])
s = [e.ljust(max_len, '0') for e in s]
p = [str(e).rjust(3, '0') for e in p]
m = [str(e).rjust(3, '0') for e in range(1, n+1)]

merged = [s[i]+p[i]+m[i] for i in range(n)]

merged.sort()

for i in range(n):
    print(int(merged[i][-3:]))

Solution (Python):
N = int(input())
rests = []
for i in range(N):
	S,P = input().split()
	rests.append((S,int(P),i+1))

rests.sort(key=lambda x: (x[0],-x[1]))

for rest in rests:
	print(rest[2])

Solution (Python):
n = int(input())
e = [[i for i in input().split()] for i in range(n)]

for i in range(n):
    e[i][1]=(-1)*int(e[i][1])
for i in range(n):
    e[i]+=[i+1]
e.sort()
for i in range(n):
    print(e[i][2])

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
S = [None] * N

for i in range(N):
    t = input().strip().split()
    
    S[i] = [t[0], int(t[1]), i]
    
S.sort(key = lambda x:(x[0], -x[1]))

for v in S:
    print(v[2] + 1)

Solution (Python):
import numpy as np
N= int(input())
s_list = []
p_list = []
for _ in range(N):
    s, p = input().split()
    s_list.append(s)
    p_list.append(int(p))

s_unique = list(set(s_list))
s_unique.sort()
for s in s_unique:
    ps = []
    indexs = [i for i,x in enumerate(s_list) if x==s]
    for index in indexs:
        ps.append(p_list[index])
    ps_sorted_index = np.argsort(ps)[::-1]
    for i in ps_sorted_index:
        print(indexs[i]+1)

Solution (Python):





from sys import stdin





import numpy as np

a = int(stdin.readline().split()[0])
n = []
for i in range(a):
    write = stdin.readline().split()
    n.append([write[0],-int(write[1]),i])




n2 = sorted(n, key=lambda x:(x[0], x[1]))


for el in n2:
    print(el[2]+1)

Solution (Python):

from operator import itemgetter
n = int(input())
data = []
for i in range(n):
    s, p = map(str, input().split())
    data.append([i+1, s, int(p)])
data = sorted(data, key=itemgetter(2), reverse=True)
data = sorted(data, key=itemgetter(1))
for j in range(n):
    print(data[j][0])

Solution (Python):


def main():
    N = int(input())
    SP = []
    for i in range(N):
        s, p = input().split()
        SP.append((s, -int(p), i+1))
            
    X = map(lambda x:str(x[2]), sorted(SP))
    print('\n'.join(X))


if __name__ == '__main__':
    main()

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    sp = []
    for i in range(n):
        a, b = input().split()
        b = int(b)
        sp.append([a, b, i])
    sp.sort(key=lambda x:(x[0], -x[1]))
    for arr in sp:
        print(arr[2]+1)

Solution (Python):
N = int(input())
SP = [[i+1, list(input().split())] for i in range(N)]





sorted_items = sorted(
  SP,
  key = lambda x: (x[1][0], -int(x[1][1]))
)
for i in sorted_items:
  print(i[0])

Solution (Python):
import sys
from operator import itemgetter

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()
dc = {}
for i in range(n):
    s, p= input().split()
    if s not in dc:
        dc[s] = []
        dc[s].append((i+1, int(p)))
    else:
        dc[s].append((i+1,int(p)))
dc = sorted(dc.items())
for k, v in dc:
    v.sort(key=itemgetter(1), reverse=True)
    for i in range(len(v)):
        print(v[0][0])
        v.pop(0)

Solution (Python):
N = int(input())

D = [input().split()+[i] for i in range(N)]
D = sorted(D, key=lambda x:-int(x[1]))
D = sorted(D, key=lambda x:x[0])
for i in range(N):
    print(D[i][2]+1)

Solution (Python):
n=int(input())
sp=[]
for i in range(n):
    a=input().split()
    sp.append([a[0],int(a[1]),i+1])

l=[[] for i in range(n)]
from operator import itemgetter
sp.sort(key=itemgetter(1))
sp.reverse()
sp.sort(key=itemgetter(0))

for i in range(n):
    print(sp[i][2])

Solution (Python):
N = int(input())
list = []
for i in range(N):
  r = input().split()
  list.append((r[0], 100-int(r[1]), i+1))
list.sort()
for i in range(N):
  print(list[i][2])

Solution (Python):

N = int(input())
Vs = [ input().split() for _ in range(N)]
Vs = list(map(lambda x: (x[0], int(x[1])),Vs))
Vss = sorted(Vs, key=lambda x: (x[0], -x[1]))

for v in Vss:
    print(Vs.index(v)+1)

Solution (Python):
n = int(input())
cities = {}
r = []
for i in range(n):
    c, s = input().split(" ")
    r.append([c,int(s)])
    if cities.get(c) == None:
        cities[c] = [i]
    else:
        cities[c].append(i)



for c, num in sorted(cities.items()):
    for j in sorted(num, key=lambda x:r[x][1], reverse=True):
        print(j+1)

Solution (Python):
n = int(input())
sp = [[i for i in input().split()] for i in range(n)]

dic = {}
for x,p in sp:
    if x in dic:
        dic[x].append(int(p))
    else:
        dic[x] = [int(p)]

res_l = []
for x,p in sp:
    res = 0
    flg = False
    for k in sorted(dic):
        if x != k:
            res+=len(dic[k])
        else:
            l = sorted(dic[k], reverse=True)
            
            for i in l:
                res += 1
                if int(i) == int(p):
                    flg == True
                    res_l.append(res)
                    break

        if flg:
            break

xx = [0]*n
for i,x in enumerate(res_l):
    xx[x-1] = i+1

for x in xx:
    print(x)

Solution (Python):
n = int(input())
l = []
for i in range(n):
    s,p = input().split()
    l.append([i+1,s,int(p)])


m = sorted(l,key=lambda x:(x[1],-x[2]))

for i in m:
    print(i[0])

Solution (Python):
n = int(input())
index=0
listA=[]
hashMap={}
while index < n:
    s, p = map(str, input().split())
    listA.append([s, p])
    if s in hashMap:
        hashMap[s].append(int(p))
    else:
        hashMap[s] = [int(p)]
    index+=1

answerL=[]
newHashMap={}
index=0
num = 1
keyL = list(hashMap.keys())
keyL.sort()
while index < len(keyL):
    index2=0
    listV = hashMap[keyL[index]]
    listV.sort(reverse = True)
    while index2 < len(listV):
        newHashMap[keyL[index]+str(listV[index2])]=num
        num+=1
        index2+=1
    index+=1

index=0
while index < len(listA):
    answerL.append(newHashMap[listA[index][0]+listA[index][1]])
    index+=1
newAnsL=[0]*n
index=0
while index < len(answerL):
    newAnsL[answerL[index]-1] = index+1
    index+=1
for ans in newAnsL:
    print(ans)

Solution (Python):
N=int(input())
X=[]
for i in range(N):
    s,p=map(str,input().split())
    X.append((i+1,s,int(p)))
X.sort(key=lambda x:(x[1],-x[2]))
for i in X:
    print(i[0])

Solution (Python):
N=int(input())
data=[]
for i in range(N):
  B,C=input().split()
  B=str(B)
  C=int(C)
  data.append([i+1,B,C])
  

data.sort(key=lambda x:x[2], reverse=True)
data.sort(key=lambda x:x[1])

for i in range(0,N):
  A=data[i]
  print(A[0])

Solution (Python):
N = int(input())
dic = {}
dic2 = {}
for i in range(N):
    s, p = input().split()
    dic[int(p)] = s
    dic2[int(p)] = i
dic = sorted(dic.items(), reverse=True)
for i,j in sorted(dic, key=lambda x:x[1]):
    print(dic2[i]+1)

Solution (Python):
n = int(input())
lis = []
for i in range(n):
    s,p = input().split()
    smal_lis = [s,int(p),i+1]
    lis.append(smal_lis)
lis.sort(key=lambda x:x[1],reverse=True)
lis.sort(key=lambda x:x[0])

for i in range(n):
    print(lis[i][2])

Solution (Python):
from operator import itemgetter
n = int(input())
a = list()

for i in range(0,n):
    a.append(list(input().split()))
    a[i][1] = int(a[i][1])
    a[i].append(i+1)

a.sort(key = itemgetter(1),reverse = True)
a.sort(key = itemgetter(0))

for i in range(0,n):
    print(a[i][2])

Solution (Python):
N=int(input())
sp = []
n = 1
for i in range(N):
  iin = input().split()
  Sin = iin[0]
  Pin = int(iin[1])
  sp.append( [Sin, Pin, n] )
  n+=1
sp = sorted( sp, key=lambda ii:ii[1], reverse=True)
sp = sorted( sp, key=lambda ii:ii[0])
for ss in sp:
  print(ss[2])

Solution (Python):
N = int(input())
city2l = {}
for i in range(N):
    s,p = input().split()
    p = int(p)
    if s not in city2l:
        city2l[s]=[]
    city2l[s].append([p,i+1])
l = []
for key in city2l:
    ins = city2l[key]
    ins = sorted(ins, key=lambda x:-x[0])
    for one in ins:
        l.append([key, one[1]])
l = sorted(l, key=lambda x:x[0])
for o in l:
    print(o[1])

Solution (Python):
N = int(input())

lst = []
for i in range(N):
    s, p = input().split()
    town = [s, int(p), i + 1]
    lst.append(town)


lst.sort(key=lambda x: (x[0],-x[1]))


for a in lst:
    print(a[2])

Solution (Python):
from collections import defaultdict

N = int(input())

city = defaultdict(list)
for i in range(N):
    S, P = input().split()
    city[S].append((int(P), i + 1))

for i, (name, tup) in enumerate(sorted(city.items())):
    for score, num in sorted(tup, reverse=True):
        print(num)

Solution (Python):
def solve():
  N = int(input())
  SP = [[i for i in input().split()] for s in range(N)]
  name = []
  dictionary = {}
  for i in range(N):
    S, P = SP[i]
    if S not in dictionary:
      dictionary[S] = []
      name.append(S)
    dictionary[S].append([i + 1, int(P)])
  name.sort()
  for n in name:
    d = sorted(dictionary[n], key=lambda x: x[1], reverse=True)
    for _d in d:
      print(_d[0])

solve()

Solution (Python):
n = int(input())
rs = [input().split() for _ in range(n)]
rs = [(r, int(p)) for r, p in rs]
srs = sorted(sorted(rs, key=lambda p: p[1], reverse=True), key=lambda p: p[0])
 
for p in srs:
  print(rs.index(p)+1)

Solution (Python):
n=int(input())
from collections import defaultdict
d=defaultdict(list)
for i in range(n):
    s,p=input().split()
    d[s].append((int(p),i+1))
keys=sorted(d.keys())


for key in keys:
    for item in sorted(d[key],key=lambda x : x[0],reverse=True):
        print(item[1])

Solution (Python):
N = int(input())
res = []

for i in range(N):
  S, P = input().split()
  P = int(P)
  res.append([i, S, P])
  
res.sort(key=lambda x: x[1])
buf = []

for e in res:
  if len(buf) == 0 or buf[-1][1] == e[1]:
    buf.append(e)
  else:
    buf.sort(key=lambda x: -x[2])
    for f in buf:
      print(f[0] + 1)
    buf = [e]

if len(buf) > 0:
  buf.sort(key=lambda x: -x[2])
  for f in buf:
    print(f[0] + 1)

Solution (Python):
n=int(input())

li=[]
for i in range(1,n+1):
    s=input().split()
    s.append(i)
    s[1]=int(s[1])*-1
    li.append(s)


lis = sorted(li)


for i in range(0,n):
    print(lis[i][2])

Solution (Python):
from operator import itemgetter

N = int(input())
X = [None for _ in range(N)]
for i in range(N):
    Si, Pi = input().split()
    Pi = int(Pi)
    X[i] = list((Si, Pi, i + 1))
X.sort(key=itemgetter(1), reverse=True)
X.sort(key=itemgetter(0))

for x in X:
    print(x[2])

Solution (Python):
N = int(input())
lst = []
for i in range(N):
  s,p = input().split()
  p=int(p)
  lst.append((s,-p,i+1))
lst.sort()
for e in lst:
  print(e[2])

Solution (Python):
n=int(input())
SP=[list(map(str,input().split())) for __ in range(n)]
for i in range(len(SP)):
    SP[i][1] = str(SP[i][1]).zfill(3)
    SP[i].extend([i+1])

SP.sort(key=lambda x:x[1],reverse=True)
SP.sort(key=lambda x:x[0])

for s in SP:
    print(s[2])

Solution (Python):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

def main():
    N = II()
    li = []
    for i in range(N):
        S, P = LS()
        li.append([S, int(P), i])

    li = sorted(li, key= lambda x: (x[0], -x[1]))
    for j in li:
        print(j[2]+1)

main()

Solution (Python):
def f(l):
    a, b, c = l
    return int(b)

def f2(l):
    a, b, c = l
    return a

N = int(input())
SP = [list(map(str, input().split())) for _ in range(N)] 

for _ in range(len(SP)):
    SP[_].append(_+1)

SP.sort(key=f, reverse=True)
SP.sort(key=f2)

for _ in SP:
    print(_[2])

Solution (Python):



def main():
    n = int(input())
    rest = dict()

    for i in range(n):
        si, pi = input().split()

        if si not in rest.keys():
            rest[si] = [(i + 1, int(pi))]
        else:
            rest[si].append((i + 1, int(pi)))

    for key, values in sorted(rest.items(), key=lambda x: x[0]):
        for no, values in sorted(values, key=lambda y: y[1], reverse=True):
            print(no)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
SP = [input().split() for i in range(N)]
SP = [[sp[0], int(sp[1]), i+1]for i, sp in enumerate(SP)]
SP = sorted(SP, reverse=True, key=lambda x: x[1])
SP = sorted(SP, key=lambda x: x[0])
for s, p, i in SP:
    print(i)

Solution (Python):
n = int(input())
sp = []

for i in range(1, n+1):
    s, p = [_ for _ in input().split()]
    sp.append([i, s, int(p)])

for e in sorted(sp, key=lambda x: (x[1], -x[2])):
    print(e[0])

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
data = []
for i in range(N):
    city, value = input().strip().split(' ')
    data.append((city, int(value), i+1))
data.sort(key=lambda x: x[1], reverse=True)
data.sort(key=lambda x: x[0])
for i in range(N):
    print(data[i][2])

Solution (Python):
n = int(input())
sp_list = [list((input().split(),i+1)) for i in range(n)]
sp_list = sorted(sp_list, key=lambda x:(int(x[0][1])),reverse = True)
sp_list = sorted(sp_list, key=lambda x:(x[0][0]))

for i in range(n):
    print(sp_list[i][1])

Solution (Python):
n = int(input())
r = []
for i in range(n):
    c, s = input().split()
    r.append((c, -int(s), i+1))
r = sorted(r)
for x in r:
    print(x[2])

Solution (Python):
n = int(input())
res = []
for i in range(n):
    s, p = input().split()
    p = int(p)
    res.append([i+1, s, p])

res = sorted(res, key=lambda x:x[2], reverse=True)
res = sorted(res, key=lambda x:x[1], reverse=False)
for r in res:
    print(r[0])

Solution (Python):

import sys
from collections import defaultdict


def solve(N: int, S: "List[str]", P: "List[int]"):
    d = defaultdict(list)

    for i,(s,p) in enumerate(zip(S,P)):
        d[s].append((i,p))
    d = sorted(d.items())

    for k,v in d:
        v.sort(key=lambda x:x[1],reverse = True)
        for vv in v:
            print(vv[0]+1)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [str()] * (N)  
    P = [int()] * (N)  
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    s,p=input().split()
    pp=int(p)
    l.append([s,pp,i])
l.sort(key=lambda x:x[0])
buf=l[0][0]
b=n
m=[]
for i in range(n):
    [s,p,index]=l[i]
    if (buf!=s):
        b-=1
        buf=s
    m.append([b*100+p,index,s])
m.sort(key=lambda x:x[0],reverse=True)
for i in range(n):
    print(m[i][1]+1)

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    l.append(list(input().split())+[i+1])
l=sorted(l, key=lambda x: x[0])
s=sorted(set([x[0] for x in l]))
for c in s:
    x=sorted([a for a in l if a[0]==c], key=lambda x: int(x[1]))[::-1]
    for a in x:
        print(a[2])

Solution (Python):

if __name__ == '__main__':
    n = int(input())
    d = {}
    for i in range(n):
        s,p = input().split()
        p = int(p)
        if( s not in d ):
            d[s] = []
        temp = d[s]
        temp.append([p,i])
    
    k = d.keys()
    k = sorted(k)
    for i in k:
        d[i].sort(key=lambda x: -x[0])
        for j in d[i]:
            print(j[1] + 1)

Solution (Python):
n=int(input())
dat = []
for i in range(n):
    s,t = input().split()
    t = int(t)
    dat.append([s, -t, i + 1])
dat.sort()
for i in range(n):
    print(dat[i][2])

Solution (Python):
n = int(input())

sp = [list(input().split()) for i in range(n)]
for index, sp_t in enumerate(sp):
        sp_t.append(index)
sp.sort(key=lambda x:int(x[1]), reverse=True)

sp.sort(key=lambda x:x[0])


for sp_t in sp:
        print(sp_t[2]+1)

Solution (Python):
N = int(input())
L = [[0]*3 for i in range(N)]

for i in range(N):
    S, P = map(str, input().split())
    P = int(P)
    L[i][0] = S
    L[i][1] = P
    L[i][2] = i+1

tmp = sorted(L, key=lambda x: x[1], reverse=True)
ans = sorted(tmp, key=lambda x: x[0])
for a in ans:
    print(a[2])

Solution (Python):
from operator import itemgetter

n = int(input())
sp = [input().split() for i in range(n)]

sorted_sp = sorted(sp,key = lambda x: int(x[1]), reverse=True)
sorted_sp = sorted(sorted_sp,key = itemgetter(0))

for i in range(n):
    for j in range(n):
        if sp[j] == sorted_sp[i]:
            print(j+1)

Solution (Python):
N = int(input())
s = [(lambda x, v: (x, -int(v)))(*input().split()) for i in range(N)]
s2 = s.copy()

s.sort()
for i in s:
    print(s2.index(i)+1)

Solution (Python):
n = int(input())
d = dict()
name_list = []
for j in range(n):
    s, i = input().split()
    if s not in d.keys():
        d[s] = []
    d[s].append([int(i), j])
    name_list.append(s)
name_list = list(set(name_list))
name_list.sort()
for t in name_list:
    tar = sorted(d[t], reverse=True)
    for ans in tar:
        print(ans[1] + 1)

Solution (Python):

from operator import itemgetter

N = int(input())
data = []
for i in range(N):
    r = input().split()
    data.append((r[0], int(r[1]), i+1))

data = sorted(sorted(data, key=itemgetter(1), reverse=True), key=itemgetter(0))

for d in data:
    print(d[2])

Solution (Python):
n = int(input())
sp = [list(input().split()) for _ in range(n)]
for i in range(len(sp)):
    sp[i][1] = int(sp[i][1])
d = sorted(sp, key=lambda x:(x[0],-x[1]))
for i in range(len(sp)):
    print(sp.index(d[i])+1)

Solution (Python):
N = int(input())
L = []
for i in range(N):
    l = list(map(str, input().split()))
    l[1] = int(l[1])
    l.append(i+1)
    L.append(l)
L = sorted(L, key=lambda x:(x[0],-x[1]) )

for i in range(N):
    a = L[i][2]
    print(a)

Solution (Python):
n = int(input())
a = (input().split() for _ in range(n))
for x in sorted((s, -int(p), i) for i, (s, p) in enumerate(a, 1)):
    print(x[2])

Solution (Python):
n = int(input())

rest_list = []
for i in range(n):
    rest, point = input().split()
    point = int(point)
    rest_list.append([rest, point, i+1])

for k, v, t in sorted(rest_list, key=lambda x: (x[0],-x[1])):
    print(t)

Solution (Python):
import numpy as np

N = int(input())
S = []
P = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    S.append(s)
    P.append(p)

for n in sorted(set(S)):
    d = []
    p = []
    for i in range(N):
        if S[i] == n:
            d.append(i)
            p.append(P[i])

    for i in np.argsort(p)[::-1]:
        print(d[i] + 1)