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())
SP=[list(input().split()) for _ in range(N)]

base=[]

for i in range(N):
    SP[i].append(i+1)
    SP[i][1]=int(SP[i][1])

sp=sorted(SP)



for i in range(1,N):
    if sp[i][0]==sp[i-1][0]:
        base.append(sp[i-1][1:])
    else:
        base.append(sp[i-1][1:])
        base=sorted(base,reverse=True)
        for j in base:
            print(j[1])
        base=[]
    
if sp[N-1][0]==sp[N-2][0]:
        base.append(sp[N-1][1:])
        base=sorted(base,reverse=True)
        for j in base:
            print(j[1])
        base=[]
else:
    print(sp[N-1][2])

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

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

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

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

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

Solution (Python):

n=int(input())
sp=[]
for i in range(1,n+1):
    s,p=input().split()
    p=int(p)
    sp.append((s,p,i))
sp.sort(key=lambda x:(x[0],-x[1]))

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

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

r_dic = {}

for i in range(N):
    si,ppi = input().split()
    pi = int(ppi)
    if si in r_dic.keys():
        r_dic[si].append((i+1,pi))
    else:
        r_dic[si] = [(i+1,pi)]
    
skey = sorted(r_dic.keys())
for key in skey:
    line = r_dic[key]
    if len(r_dic[key]) == 1:
        print(line[0][0])
    else:
        sline = sorted(line, key = lambda x:x[1], reverse=True)
        for s in sline:
            print(s[0])

Solution (Python):
n = int(input())
jisyo = dict()
for i in range(n):
    city , point = input().split()
    if city in jisyo.keys():
        jisyo[city].append((int(point),i))
    else:
        jisyo[city] = [(int(point),i)]

jisyo_sort = sorted(jisyo.items() , key = lambda x : x[0])

for c in jisyo_sort:
    point_sort = sorted(c[1] , key = lambda x : x[0] , reverse = True)
    for i in point_sort:
        print(i[1]+1)

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

Solution (Python):


def main():
    n = int(input())
    spi = []
    for i in range(n):
        s, p = input().split()
        spi.append((s, -int(p), i))
    spi = sorted(spi)
    for s, p, i in spi:
        print(i + 1)

if __name__ == "__main__":
    main()

Solution (Python):



from collections import defaultdict

def main():
  n = int(input())
  sp = defaultdict(list)
  sp2number = {}
  for i in range(n):
    s, p = input().strip().split()
    p = int(p)
    sp[s].append(p)
    sp2number[(s, p)] = i + 1
  for key in sorted(sp.keys()):
    for score in sorted(sp[key], reverse=True):
      print(sp2number[(key, score)])

if __name__=='__main__':
  main()

Solution (Python):


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

A=sorted(S,key=lambda x:int(x[1]), reverse=True)
B=sorted(A,key=lambda x:x[0])

for i in range(N):
    ans=S.index(B[i])+1
    print(ans)

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

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

    r.sort(key=lambda val: (val[0], val[1]))

    for v in r:
        print(v[2])


main()

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

spi = []
for i in range(n):
    spi.append([sp[i][0], -1*int(sp[i][1]), i])

spi.sort()

for _spi in spi:
    print(_spi[2]+1)

Solution (Python):
N = int(input())
SP = {}
ALL = {}
for i in range(N):
    [Stmp, Ptmp] = list(input().split())
    if Stmp not in SP:
        SP[Stmp] = [int(Ptmp)]
    else:
        SP[Stmp].append(int(Ptmp))
    ALL[Stmp+str(Ptmp)] = i+1

A = list(SP.keys())
A.sort()
M = len(A)
for i in range(M):
    L = SP[A[i]]
    L.sort(reverse=True)
    for j in range(len(L)):
        print(ALL[A[i]+str(L[j])])

Solution (Python):
from collections import defaultdict
from itertools import chain
n = int(input())
a = [input().split() + [i+1] for i in range(n)]
d = defaultdict(list)
for k,v,i in a:
    d[k].append((int(v), i))


sk = sorted(d.keys())
sd = [sorted(d[ski], reverse=True) for ski in sk]
[print(i) for v,i in chain.from_iterable(sd)]

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

d = [input().split() + [i+1] for i in range(n)]
d = sorted(d, key=lambda x:int(x[1]), reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=False)
for s in d:
    print(s[-1])

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

d = [input().split() + [i+1] for i in range(N)]
d = sorted(d, key=lambda x:int(x[1]), reverse=True)
d = sorted(d, key=lambda x:x[0], reverse=False)
for s in d:
    print(s[-1])

Solution (Python):
N = int(input())
guide = dict()
for i in range(N):
  s, p = input().split()
  city, point = str(s), int(p)
  
  if city in guide.keys():
    guide[city].append((point, i))
  else:
    guide[city] = [(point, i)]



guide_asc = sorted(guide.items(), key=lambda x: x[0])


for city_guide in guide_asc:
  
  city_guide_desc = sorted(city_guide[1], key=lambda x: x[0], reverse=True)
  
  
  for rest in city_guide_desc:
    print(rest[1] + 1)

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

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

beta = sorted(lst, key=lambda x: x[1], reverse=True)
alpha = sorted(beta, key=lambda x: x[0])

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

Solution (Python):
lst = list()
for idx in range(int(input())):
  k,v = input().split()
  lst.append((k,int(v), idx+1))
lst.sort(key=lambda t: (t[0],-t[1]), reverse=False)
for t in lst:
  print(t[2])

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

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

sp_sort = sorted(sp, key=lambda x: (x[0], -1 * x[1]))

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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
list = []
for i in range(N) :
    s, p = input().split()
    list.append((s,p,i+1))

list.sort(key = lambda x: (x[0],-1*int(x[1])))
for i in range(N) :
    print(list[i][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])

for i in sorted(lst):
    print(i[2])

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

id = 0
res = []
for i in range(n):
    id += 1
    s, p = map(str, input().split())
    res.append([s, -1 * int(p), id])

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

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

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

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

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

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

name = []
score = []
for i in range(n):
    a, b = input().split()
    b = int(b)
    name.append(a)
    score.append(b)
rank = []

N = sorted(list(set(name)))
A = []
B = []
t = 1
for i in N:
    A = []
    B = []
    for j in range(n):
        if name[j] == i:
            A.append(j)
            B.append(score[j])

    C = zip(B, A)
    C = list(reversed(sorted(C)))
    D, E = zip(*C)

    for i in E:
        print(i+1)

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

r_dic = {}

for i in range(N):
    si,ppi = input().split()
    pi = int(ppi)
    if si in r_dic.keys():
        r_dic[si].append((i+1,pi))
    else:
        r_dic[si] = [(i+1,pi)]
    
skey = sorted(r_dic.keys())
for key in skey:
    line = r_dic[key]
    if len(r_dic[key]) == 1:
        print(line[0][0])
    else:
        sline = sorted(line, key = lambda x:x[1], reverse=True)
        for s in sline:
            print(s[0])

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

for i in range(n):
  s, m = input().split()
  sp[i][0] = s
  sp[i][1] = -int(m)
  sp[i][2] = i

sp.sort()
for s, n, i in sp:
  print(i+1)

Solution (Python):
from operator import itemgetter 
n=int(input())
data=[]
name=[]
for i in range(n):
    s_i,p_i=input().split()
    data.append([s_i,100-int(p_i),i+1])
data.sort()
for i in range(n):
    print(data[i][2])

Solution (Python):
n = int(input())
X = [["0", "0", 0]]
for i in range(n):
    s, p = map(str, input().split())
    X.append([s, p, i + 1])
X = sorted(X, key = lambda x : x[0])
X.append(["0", "0", 0])
Y = []
for i in range(1, n + 1):
    if X[i][0] != X[i + 1][0] and X[i - 1][0] != X[i][0]:
        print(X[i][2])
    elif X[i][0] == X[i + 1][0]:
        Y.append([X[i][1], X[i][2]])
    elif X[i][0] != X[i + 1][0] and X[i - 1][0] == X[i][0]:
        Y.append([X[i][1], X[i][2]])
        Y = sorted(Y, key = lambda x : int(x[0]))
        Y.reverse()
        for j in range(len(Y)):
            print(Y[j][1])
        Y = []

Solution (Python):
n=int(input())
sp=[list(input().split()) for _ in range(n)]
for i in range(n):
  sp[i][1]=int(sp[i][1])*(-1)
  sp[i].append(i+1)
sp.sort()
for i in range(n):
  print(sp[i][2])

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

Solution (Python):

N = int(input())
SP = []
for i in range(N):
    s, n = input().split()
    n = int(n)
    SP.append((s, -n, i))
SP.sort()

for s, n, i in SP:
    print(i+1)

Solution (Python):


def readints():
    return list(map(int, input().split()))


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

SP.sort()
for s, p, i in SP:
    print(i+1)

Solution (Python):
N = int(input())
table = []
for i in range(N):
    tmp = list(input().split())
    tmp[1] = int(tmp[1]) * (-1)
    tmp_table = [tmp, i+1]
    table.append(tmp_table)
table.sort()
for i in range(N):
    print(table[i][1])

Solution (Python):
N = int(input())
f = lambda x: (x[0], int(x[1]))
SP = tuple(f(input().split()) for _ in range(N))
print(*sorted(range(1, N+1), key=lambda i: (SP[i-1][0], -SP[i-1][1])), sep='\n')

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

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

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

restrunt=[]

for i in range(n):
    a, b = input().split()
    restrunt.append( {"s":a, "p":int(b), "nom":i+1} )

restrunt.sort(key=lambda res:res["p"], reverse=True)
restrunt.sort(key=lambda res: res["s"])

for res in restrunt:
    print(res["nom"])

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

x=sorted(rest)


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

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

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

for i in range(n):
    sp[i][1] = int(sp[i][1])
    sp[i] = sp[i]+[i+1]
    
sp_s0 = sorted(sp, key=lambda x:(x[0], -x[1]), reverse=False)

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

Solution (Python):


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

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

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

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

for i in range(n):
    s, p = map(str, input().split())
    log.append([s, int(p), i])

b = sorted(log, key=lambda x: x[0])
c = sorted(log, key=lambda x: x[1], reverse=True)

num = []

for i in range(n):
    for j in range(n):
        if b[i][0] == c[j][0]:
            if c[j][2] not in num:
                print(c[j][2]+1)
                num.append(c[j][2])

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

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


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

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

Solution (Python):
n = int(input())
lst = []
for i in range(n):
    s,p = input().split()
    lst.append([s,-int(p),i+1])
lst.sort()
for i in range(n):
    print(lst[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.sort()

for i in l:
 print(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.sort()

for name, p, inx in l:
 print(inx)

Solution (Python):
n=int(input())
l=sorted([input().split()+[i] for i in range(n)])+[['',0,0]]

b_n=l[0][0]
t_list=[]

for name, p, inx in l:
 if name!=b_n:
  t_list.sort(reverse=True)
  for i,j in t_list:
   print(j+1)
  t_list=[]
  b_n=name

 t_list.append([int(p),inx])

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

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

b_name=l[0][0]
t_list=[]

for name, point, inx in l:
 if name==b_name:
  t_list.append([int(point),inx])
 else:
  t_list.sort(reverse=True)
  for i,j in t_list:
   print(j+1)
  t_list=[]
  t_list.append([int(point),inx])
  b_name=name

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

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

l.sort(key=lambda x:(x[0],-x[1]))
for _, _, i in l:
    print(i)

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

li = []

for i in range(n):
    s,p = map(str, input().split())
    p = int(p)
    li.append((s,p,i))

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

for i in range(n):
    print(li[i][2] + 1)

Solution (Python):
from operator import itemgetter
n=int(input())
s=[input().split() for i in range(n)]
t=sorted(s,key=lambda x:(x[0],-int(x[1])))
[print(s.index(i)+1) for i in t]

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

flag=1
finished=0
while flag:
    flag=0
    for i in range(N-1-finished):
        if lst[i][0]==lst[i+1][0] and lst[i][1]<lst[i+1][1]:
            lst[i],lst[i+1]=lst[i+1],lst[i]
            flag=1
    finished+=1

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

Solution (Python):



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

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

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

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

Solution (Python):




def main():
    N = int(input())
    SP = []
    for i in range(N):
        S, P = input().split()
        SP.append([i + 1, S, int(P)])

    SP.sort(key=lambda x: (x[1], -x[2]))
    for sp in SP:
        print(sp[0])


if __name__ == "__main__":
    main()

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

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

    book = []

    for i in range(N):
        S, P = input().split()
        P = int(P)
        book.append((i + 1, S, P))

    book.sort(key=lambda x: (x[1], x[2] * -1))

    for i, _, _ in book:
        print(i)


main()

Solution (Python):
n = int(input())
hako = []
for i in range(n):
    a,b = input().split()
    hako.append([a,int(b)*-1])
kari = hako.copy()
hako.sort()
for i in range(n):
    print(kari.index(hako[i])+1)

Solution (Python):
from operator import itemgetter
N=int(input())
hako=[]
for i in range(N):
    A,B=input().split()
    hako.append([A,int(B)*-1])
kari=hako.copy()

hako.sort()

for i in range(N):
    print(kari.index(hako[i])+1)

Solution (Python):
from operator import itemgetter
N=int(input())
hako=[]
for i in range(N):
    A,B=input().split()
    hako.append([A,int(B)*-1])
kari=hako.copy()

hako.sort()
hako=sorted(hako,key=itemgetter(0,1))

for i in range(N):
    print(kari.index(hako[i])+1)

Solution (Python):
n = int(input())
li = []
for i in range(n):
    s,p = input().split()
    li.append([s,-int(p)])
b = sorted(li)
for i in range(n):
    for j in range(n):
        if b[i][0] == li[j][0] and b[i][1] == li[j][1]:
            print(j+1)

Solution (Python):
n=int(input())
s = [input().split() for i in range(n)]
c=0
for x in s:
    c+=1
    x.append(c)
    x[1]=str(100-int(x[1])).zfill(3)
s.sort(key=lambda x:(x[0],x[1]))
for x in s:
    print(x[2])

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

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

for i in range(n):
    s,p = input().split()
    pi = int(p)
    lis.append([s,pi*-1,int(i+1)])
ans = sorted(lis)

for j in ans:
    print(j[2])

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

Solution (Python):
n = int(input())
hoge = []
for i in range(1, n+1):
    tmp = input().split()
    name = tmp[0]
    score = int(tmp[1])
    hoge.append((i, name, score))

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

Solution (Python):
n = int(input())
rs = [list(input().split()) for _ in range(n)]


new_rs = sorted(rs, key=lambda x: - int(x[1]))


def mp_count(s):
    mps = {}
    for mp, _ in s:  
        if mp not in mps:
            mps[mp] = 0
    return sorted(mps)


for m in mp_count(rs):
    for r in new_rs:
        if m == r[0]:
            print(rs.index(r) + 1)

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

for i in range(N):
    name, score = input().split()
    score = int(score)
    Restaurant.append([name, -score, i+1])

Restaurant.sort()

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

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

Solution (Python):
from operator import itemgetter
N = int(input())
restrant = []
for i in range(N):
    mise = [j for j in input().split()]
    L = []
    for k in range(2):
        if k == 0:
            L.append(mise[k])
        else:
            L.append(int(mise[k]))
    restrant.append(L+[i+1])
restrant.sort(key = lambda x:(x[0],-x[1]))
for i in restrant:
    print(i[2])

Solution (Python):
n=int(input())
x=[]
for i in range(n):
    key,val=map(str,input().split())
    x.append([key,-int(val),i+1])
dic_sort=sorted(x, key=lambda x:(x[0],x[1]))
for i in range(n):
    print(dic_sort[i][2])

Solution (Python):
n = int(input())
dic = {}
for i in range(1, n+1):
    n, p = input().split()
    if n not in dic.keys(): dic[n] = []
    dic[n].append([int(p), i])
keys = sorted(list(dic.keys()))
for key in keys:
    city = dic[key]
    city = sorted(city, key=lambda x: x[0], reverse=True)
    for city_i in city:
        print(city_i[1])

Solution (Python):
n = int(input())
restaurant = []
for i in range(n):
  s, p = input().split()
  d = str(100 - int(p))
  restaurant.append((s + '0' * (13 - len(s) - len(d)) + d, i+1))
restaurant.sort()
for rest in restaurant:
  print(rest[1])

Solution (Python):
n = int(input())
l = [0] * n
for i in range(n):
    l[i] = list(map(str, input().split()))
    l[i][1] = int(l[i][1])
l_sorted = sorted(l, key=lambda l: l[1], reverse=True)
l_sorted = sorted(l_sorted, key=lambda l: l[0])

for i in range(len(l)):
    print(l.index(l_sorted[i]) + 1)

Solution (Python):
n = int(input())
ans = {}
for i in range(1,n+1):
    s,t = input().split()
    ans[i] = [s,-1*int(t)]
ans = sorted(ans.items(),key = lambda x:x[1])
for i in range(n):
    print(ans[i][0])

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

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

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

Solution (Python):
import sys
from collections import defaultdict

n = int(sys.stdin.readline().rstrip())
sp = [sys.stdin.readline().split() for _ in range(n)]

def main():
    res = defaultdict(list)
    for i in range(n):
        s, p = sp[i]
        res[s].append((int(p), i+1))
    
    for s, l in sorted(res.items()):
        for p, i in sorted(l, reverse=True):
            yield i

if __name__ == '__main__':
    ans = main()
    print(*ans, sep='\n')

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007



def main():
	n = int(input())
	ll=[]
	for i in range(n):
		b , c = input().split()
		c=int(c)
		ll.append((b,-c,i+1))
	ll.sort()
	for _, _, i in ll:
		print(i)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
from operator import itemgetter


N = int(input())
S, P = ['0']*N, [0]*N
SP = []
for i in range(N):
    tmp_s, tmp_p = map(str, input().split())
    S[i], P[i] = tmp_s, tmp_p
    SP.append((tmp_s,int(tmp_p)))


SSP = sorted(SP, key=itemgetter(1), reverse=True)

SSP = sorted(SSP, key=itemgetter(0))

answer = [0]*N
for i in range(N):
    for j in range(N):
        if SSP[i] == SP[j]:
            answer[i] = j+1

for i in answer:
    print(i)

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 j in range(len(l)):
  print(l[j][2])

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

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

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

Solution (Python):
N = int(input())
d = dict()
cities = set()
for n in range(N):
    i = n + 1
    S, P = [s for s in input().split(' ')]
    cities.add(S)
    P = int(P)
    Ps = d.get(S, [])
    Ps.append((P, i))
    d[S] = Ps
for city in sorted(d.keys()):
    rs = d[city]
    for r, i in sorted(rs, reverse=True):
        print(i)

Solution (Python):
import os, sys, re, math

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

SP = sorted(SP, key=lambda k:k[1], reverse=True)
SP = sorted(SP, key=lambda k:k[0])

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

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

Solution (Python):
n = int(input())
s = list([input() for _ in range(n)])

for x in sorted(enumerate(s), key=lambda x: (x[1].split()[0], -int(x[1].split()[1]))):
    print(x[0] + 1)

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    name, p = input().split(' ')
    p = int(p)
    d[name] = d.get(name, []) + [(-p, i+1)]
for key in sorted(d):
    d[key] = sorted(d[key])
    for i in range(len(d[key])):
        print(d[key][i][1])

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

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

Solution (Python):
n=int(input())
rest=[input().split()+[i+1] for i in range(n)]
rest.sort(key=lambda i:(i[0],-int(i[1])))
ans=[rest[i][2] for i in range(n)]
print(*ans,sep='\n')

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

rest.sort(key=lambda i:i[0])

cnt=0
for i in range(1,n):
  if rest[i-1][0]==rest[i][0]:
    continue
  else:
    res=rest[cnt:i]
    res.sort(key=lambda i:i[1],reverse=True)
    
    for j in range(i-cnt):
      print(res[j][2])
    cnt=i
    
res=rest[cnt:n]

res.sort(key=lambda i:i[1],reverse=True)
for i in range(n-cnt):
  print(res[i][2])

Solution (Python):
a = range(1, int(input())+1)
b = sorted(a, key=lambda _:[(s, -int(p)) for s, p in[input().split()]])
print(*b)

Solution (Python):
N = int(input())
L = [input().split() + [i+1] for i in range(N)]
L.sort(key=lambda x: (x[0], -int(x[1])))
print(*[n[2] for n in L], sep='\n')

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

beta = sorted(lst, key=lambda x: x[1], reverse=True)
alpha = sorted(beta, key=lambda x: x[0])

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

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

sp = []

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


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


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

Solution (Python):
a = range(1, int(input())+1)
b = sorted(a, key=lambda _:[(s, -int(p)) for s, p in[input().split()]])
print(*b)

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

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

Solution (Python):
from collections import defaultdict
N = int(input())
dic = defaultdict()
for i in range(1, N+1):
  k, v = input().split()
  dic[i] = [k, int(v)]
  
sorted_dic = sorted(dic.items(), key=lambda x:(x[1][0], -x[1][1]))
for k, *v in sorted_dic:
  print(k)

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

lista = []
for i in range(N):
    lista.append((SP[i][0],int(SP[i][1]),i+1))

SP_sorted1 = sorted(lista, key=lambda x:x[1], reverse=True)
SP_sorted2 = sorted(SP_sorted1, key=lambda x:x[0])

for j in SP_sorted2:
    print(j[2])

Solution (Python):
def main(N, lst):
    L = []
    for i in range(len(lst)):
        target = lst[i]
        L.append({"id":i+1, "store":target[0], "point":int(target[1])})
    L.sort(key = lambda x:x["point"], reverse = True)
    L.sort(key = lambda x:x["store"])
    for i in range(len(L)):
        print(L[i]["id"])

N = int(input())
lst = list(list(map(str, input().split())) for _ in range(N))
main(N, lst)

Solution (Python):
def main(N, lst):
    L = []
    for i in range(len(lst)):
        target = lst[i]
        L.append({"id":i+1, "store":target[0], "point":int(target[1])})
        L.sort(key = lambda x:x["point"], reverse = True)
        L.sort(key = lambda x:x["store"])
    for i in range(len(L)):
        print(L[i]["id"])

N = int(input())
lst = list(list(map(str, input().split())) for _ in range(N))
main(N, lst)

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

S=[""]*N
P=[0]*N
for i in range(N):
    S[i],P[i] = input().split()
    
P = [int(s) for s in P]

list=[]
for i in range(N):
    cnt = 1
    for j in range(N):
        if i == j:
            continue
        if S[i] > S[j]:
            cnt += 1
        if S[i] == S[j] and P[i]<P[j]:
            cnt +=1
    list.append(cnt)

for i in range(1,N+1):
    print(list.index(i) + 1)

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

for i in range(n):
    s,p=input().split()
    d.append((s,100-int(p),i+1))

d.sort()
for i in range(n):
    print(d[i][2])

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

d=sorted(d)
for i in range(N):
    print(d[i][2])

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

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

Solution (Python):
N=int(input())
L=[]
for i in range(N):
  s,p=map(str, input().split())
  p=-int(p)
  L.append([s,p,i+1])

L.sort()
for j in range(N):
  print(L[j][2])

Solution (Python):



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

Solution (Python):
def main():
    n = int(input())
    str_list = []
    for i in range(n):
        str_list.append(list(input().split() + [i+1]))

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

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

if __name__ == '__main__':
    main()