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())
d={}
k=[]
for x in range(N):
  S,P=input().split()
  if S not in k:
    k.append(S)
    d[S]=[]
  d[S].append([int(P),x+1])
k.sort()
for y in k:
  d[y].sort(reverse=True)
  for z in range(len(d[y])):
    print(d[y][z][1])

Solution (Python):

















































































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    
    N = int(lines[0])
    
    
    
    
    
    
    
    
    

    tmps1 = list()
    tmps2 = list()
    for i in range(1, N+1):
        s, p = lines[i].split()
        
        tmp = (s+(' ')*10)[:11] + str(200-int(p))
        tmps1.append(tmp)
        tmps2.append(tmp)
    tmps1.sort()

    results = list()
    for tmp1 in tmps1:
        for i in range(N):
            if tmps2[i] == tmp1:
                results.append(i+1)

    return results



def get_input_lines():
    line = input()
    N = int(line)
    lines = list()
    lines.append(line)
    for _ in range(N):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['6', 'khabarovsk 20', 'moscow 10', 'kazan 50', 'kazan 35', 'moscow 60', 'khabarovsk 40']
        lines_export = [3, 4, 6, 1, 5, 2]
    if pattern == 2:
        lines_input = ['10', 'yakutsk 10', 'yakutsk 20', 'yakutsk 30', 'yakutsk 40', 'yakutsk 50', 'yakutsk 60', 'yakutsk 70', 'yakutsk 80', 'yakutsk 90', 'yakutsk 100']
        lines_export = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

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

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

for i in range(N):
  print(sp[i][0])

Solution (Python):
n = int(input())
list = []
for xi in range(n):
    add1, add2 = input().split()
    add = [int(add2), add1, xi+1]
    list.append(add)
list.sort(key=lambda list2: list2[1])


name = list[0][1]
list2 = [list[0]]
count = 1
for xi in range(1,n):
    if name == list[xi][1]:
        list2.append(list[xi])
        count += 1
    else:
        list2.sort()
        for yi in range(count-1,-1,-1):
            print(list2[yi][2])
        name = list[xi][1]
        list2 = [list[xi]]
        count = 1

if len(list2)<n:
    list2.sort()
for yi in range(count-1,-1,-1):
    print(list2[yi][2])
name = list[xi][1]
list2 = [list[xi]]
count = 1

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

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

Solution (Python):
import copy

N = int(input())
org_arr = [list(input().split()) for _ in range(N)]
for i in range(len(org_arr)):
    org_arr[i][1]=int(org_arr[i][1])
    org_arr[i].append(i+1)

arr = copy.copy(org_arr)


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

for i in range(len(arr)):
    arr[i].append(i+1)

arr.sort(key=lambda x:x[0])
for i in range(len(arr)):
    print(arr[i][2])

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

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

Solution (Python):
from operator import itemgetter
N = int(input())

T = list()
for i in range(N):
    S, P = map(str, input().split())
    T.append((S, int(P), str(i+1)))

T = sorted(T, key=itemgetter(1), reverse=True)
T = sorted(T, key=itemgetter(0))
for t in T:
    print(t[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 _, _, i in l:
    print(i)

Solution (Python):
N = int(input())
List = []
for i in range(N):
  List.append(list(map(str, input().split())))
Names = []
Points = []
for i in range(N):
  Names.append(List[i][0])
  Points.append(int(List[i][1]))
slName = set(Names)
NewName = list(slName)
NewName.sort()
Points.sort(reverse = True)
for i in range(len(NewName)):
  for j in range(len(Points)):
    for k in range(N):
      if List[k][0] == NewName[i] and int(List[k][1]) == Points[j]:
        print(k+1)
      else:
        pass

Solution (Python):
from operator import itemgetter
N = int(input())

T = list()
for i in range(N):
    S, P = map(str, input().split())
    T.append((S, int(P), str(i+1)))

T = sorted(T, key=itemgetter(1), reverse=True)
T = sorted(T, key=itemgetter(0))
for t in T:
    print(t[2])

Solution (Python):

l = []
lk = []
lv = []
n = int(input())
for _ in range(n):
    s, p = input().split()
    l.append(f"{s} {p}")
    lk.append(s)
    lv.append(int(p))



d = {}
for i in range(n):
    s, p = lk[i], lv[i]
    if s in d:
        d[s].append(p)
    else:
        d[s] = []
        d[s].append(p)



d = dict(sorted(d.items()))
for k, v in d.items():
    d[k] = sorted(v, reverse=True)
    for i in d[k]:
        print(l.index(f"{k} {i}") + 1)

Solution (Python):
def main():
  n = int(input())
  xy = [map(str, input().split()) for _ in range(n)]
  x, y = [list(i) for i in zip(*xy)]
  ans_list=list(range(0,n))
  for i in range(0,n):
    min=i
    for j in range(i+1,n):
      if x[ans_list[min]]>x[ans_list[j]] or (x[ans_list[min]]==x[ans_list[j]] and int(y[ans_list[min]])<int(y[ans_list[j]])):
        min=j
    
    if ans_list[min]!=ans_list[i]:
      tmp=ans_list[i]
      ans_list[i]=ans_list[min]
      ans_list[min]=tmp
    print(ans_list[i]+1)
  
main()

Solution (Python):
n = int(input())
s = []
p = [0] * 101
d = {}
for i in range(n):
    a,b = input().split()
    b = int(b)
    s.append(a)
    p[b] = i+1
    if a in list(d.keys()):
        d[a].append(b)
        continue
    d[a] = [b]
s = sorted(set(s))
for i in s:
    c = sorted(d[i],reverse=True)
    for j in c:
        print(p[j])

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

for n in range(N):
  s,p = input().split()
  R.append((s,-int(p),n+1))
  
for s,p,n in sorted(R):
  print(n)

Solution (Python):
def main():
    n = int(input())
    l = []
    d = {}
    for i in range(n):
        s,p = input().split()
        if s not in l:
            l.append(s)
            d[s] = []
        d[s].append([int(p), i+1])
    
    for i in sorted(l):
        for j in sorted(d[i], reverse=True):
            print(j[1])
main()

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

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

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

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

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

for i in sorted(l):
  for j in sorted(d[i], reverse=True):
    print(j[1])

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

s = sorted(s,key=lambda x:int(x[1]),reverse=True)
s = sorted(s,key=lambda x:x[0])
for i in range(n):
    print(s[i][2])

Solution (Python):
import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    N =int(input())
    l=[]
    for i in range(N):
        k,s = input().split()
        s = int(s)
        l.append([k,s,i+1])



    l.sort(reverse=True)
    mem =""
    q=[]
    for i in range(N):
        k,s,j = l.pop()
        if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
    q.sort(reverse=True)
    if q:
        for o, p in q:
            print(p)






if __name__ == "__main__":
    main()

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

for i in range(1,n+1):
    l[i-1].append(i)


for i in range(n):
    l[i][1] = (int(l[i][1]))*(-1)

sl = sorted(l)




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

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

Solution (Python):
from operator import itemgetter

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

sp.sort(key=itemgetter(0, 1))
for i in range(n):
    print(sp[i][2])

Solution (Python):
N = int(input())
L = sorted([list(input().split()) + [i + 1] for i in range(N)], key = lambda x: x[0])
while len(L) > 0:
    c = sum([x[0] == L[0][0] for x in L])
    M = sorted(L[0: c], key = lambda x : int(x[1]), reverse = True)
    for x in M:
        print(x[2])
    L = L[c:]

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

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

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

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

Solution (Python):
n = int(input())
Restaurant = []
for i in range(n):
    cmd = input().split()
    Restaurant.append([i + 1, cmd[0], int(cmd[1])])
sorted_Restaurant = sorted(Restaurant, key=lambda x: (x[1], -x[2]))
for j in sorted_Restaurant:
    print(j[0])

Solution (Python):
if __name__ == '__main__':

	n = int(input())

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

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

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 x : (x[0], -x[1]))
for x in sp:
    print(x[2])

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
SP = []
for i in range(N):
	s =rs()
	S, P = s.split(' ')
	P = int(P)
	SP.append((S, -P, i+1))

SP.sort()
for s, p, n in SP:
	print(n)

Solution (Python):
(N,),*sp = [s.split() for s in open(0)]

sp = [(s,-int(p),i+1) for i,(s,p) in enumerate(sp)]

for _,_,i in sorted(sp):
    print(i)

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

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

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

l.sort()
for i in l:
  print(i[-1])

Solution (Python):


n = int(input())

shop = []
for i in range(n):
    s, p = input().split()
    p = int(p)

    shop += [{'idx': i+1, 'val':s+f'{100-p:03}'}]

shop_sorted = sorted(shop, key=lambda x:x['val'])

for shop in shop_sorted:
    print(shop['idx'])

Solution (Python):
n = int(input())
sp = [list(map(str, input().split())) for i in range(n)]
for i in range(n):
  sp[i][1] = int(sp[i][1]) * -1
x = sorted(sp)
for i in range(n):
  print(sp.index(x[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 i in l:
    print(i[2])

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 s,p,i in l:
    print(i)

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

sp.sort()
for s,p,i in sp:
    print(i)

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

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

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

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

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

Solution (Python):
n = int(input())
d = {}
for i in range(n):
  s,p = input().split()
  if d.get(s,-1)==-1:
    d[s] = {int(p):i+1}
  else:
    d[s][int(p)] = i+1
d = sorted(d.items(), key=lambda x:x[0])
for k in d:
  l = sorted(k[1].items(), key=lambda x:x[0])[::-1]
  for t in l:
    print(t[1])

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

s1 = sorted(s,key = lambda S:S[1],reverse=True)
s2 = sorted(s1,key = lambda S:S[0])
for i in range(n):
  print(s2[i][2])

Solution (Python):
import operator as op

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

s1 = sorted(s,key = op.itemgetter(1),reverse=True)
s2 = sorted(s1,key = op.itemgetter(0))
for i in range(n):
  print(s2[i][2])

Solution (Python):
N=int(input())
ls1=[]
for i in range(N):
    si,pi=input().split()
    pi2=int(pi)
    ls2=[si,pi2,i+1]
    ls1.append(ls2)
ls1.sort(key=lambda x:-x[1])   
ls1.sort(key=lambda x:x[0])
for i in range(N):
    print(ls1[i][2])

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

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


sorted_NSP = sorted(NSP, key=lambda x: x[2], reverse=True)
sorted_NSP = sorted(sorted_NSP, key=lambda x:x[1]) 
for nsp in sorted_NSP:
    print(nsp[0])

Solution (Python):
import sys
N = int(input())
test = lambda x: [ x[0],int(x[1]) ]
array = [ [test(input().split()),int(x+1)] for x in range(N) ]

if not ( 1 <= N <= 100 ): sys.exit()
for I in array:
    if not ( 1 <= len(I[0][0]) <= 10 ): sys.exit()
    if not I[0][0].islower(): sys.exit()
    if not ( 0 <= I[0][1] <= 100 ): sys.exit()
    if not isinstance(I[0][1],int): sys.exit()

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

for I in array:
    print(I[1])

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

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

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

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

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

Solution (Python):
N = int(input())
res = [[i for i in input().split()] + [j+1] for j in range(N)]
res.sort(key = lambda x: (x[0], -int(x[1])))
print("\n".join(str(i[2]) for i in res))

Solution (Python):




n = int(input())
restaurants = []

for i in range(1, n+1):
    name, score = input().split()
    restaurants.append((name, -int(score), i))

restaurants.sort()
for i in restaurants:
    print(i[2])

Solution (Python):
n = int(input())
d = {}
for i in range(n):
    s ,p = input().split()
    p = int(p)
    if not(s in d):
        d[s] = {}
    d[s][p*-1] = i+1
for i in sorted(d.keys()):
    for j in sorted(d[i].keys()):
        print(d[i][j])

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

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

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

m = [0]*N

for i in range(N):
    k, v = input().split()
    m[i] = [k, int(v), i+1]

m.sort()

for j in range(N):
    for i in range(N-1):
        if m[i][0] == m[i+1][0] and m[i][1] < m[i+1][1]:
            m[i], m[i+1] = m[i+1], m[i]


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

Solution (Python):
N = int(input())
rev = {}
ind_dic = {}
for i in range(1, N+1):
    k, v = input().split()
    
    if k in rev:
        rev[k].append(v)
    else:
        rev[k] = [v]
    ind_dic[v] = i

for v in rev.values():
    for i in range(len(v)):
        v[i] = int(v[i])
    v.sort(reverse=True)

key_lst = []
for k in rev.keys():
    key_lst.append(k)
key_lst.sort()

new_dic = {}
for k in key_lst:
    new_dic[k] = rev[k]

for k in new_dic.keys():
    for i in range(len(new_dic[k])):
        print(ind_dic[str(new_dic[k][i])])

Solution (Python):
import numpy as np

N = int(input())
order = np.zeros(N,dtype=np.int)
SP = []
for i in range(N):
  tmp = list(input().split())
  SP.append(tmp)

for i in range(N):
  idx = 0
  for j in range(N):
    if i != j and SP[i][0] > SP[j][0]:
      idx += 1
    elif i != j and SP[i][0] == SP[j][0] and int(SP[i][1]) < int(SP[j][1]):
      idx += 1
  order[idx] = i+1
for i in range(N):
  print(order[i])

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

res.sort()
for _, _, i in res:
    print(i)

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

for i in range(N):
  SP[i][1] = -int(SP[i][1])

SP.sort()

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

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

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

ans = list(info.keys())
ans.sort(key=lambda i: info[i][1], reverse=True)
ans.sort(key=lambda i: info[i][0])
for i in ans:
    print(i)

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

cities = {}
for i in range(1, N + 1):
    s, p = input().split()
    p = int(p)
    if s in cities:
        cities[s].append((p, i))
    else:
        cities[s] = [(p, i)]
for k in cities.keys():
    cities[k] = list(sorted(cities[k], key=lambda x: x[0], reverse=True))

names = sorted(cities)
for name in names:
    for p, i in cities[name]:
        print(i)

Solution (Python):
n = int(input())
dat = []
for i in range(n):
    std_in = input().split()
    dat.append([std_in[0], int(std_in[1])])
     
for i, e in enumerate(dat, start=1):
    e[1] = -e[1]  
    e.append(i)  
     
sorted_list = sorted(dat)  
     
for i, s in enumerate(sorted_list):
    
    print(sorted_list[i][2])

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

for i in range(N):
  s,p = input().split()
  l.append([i+1,[s,-int(p)]])
  
sl = sorted(l,key=lambda w: w[1])
for w in sl:
  print(w[0])

Solution (Python):
n = int(input())
base_li = [0]*n

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

sl = sorted(base_li, key=lambda w: w[1])
for c in sl:
    print(c[0])

Solution (Python):
N=int(input())
data=[input().split() for i in range(N)]
data_name=[]
for i in range(N):
    if data[i][0] in data_name:
        continue
    else:
        data_name.append(data[i][0])
data_name_sort=sorted(data_name)

data_point=[]
for i in range(N):
    num=0
    for j in range(len(data_name_sort)):
        if data[i][0]==data_name_sort[j]:
            num+=(len(data_name)-j)*200+int(data[i][1])
        else:
            continue
    data_point.append(num)

data_sort=[i for i, _ in sorted(enumerate(data_point), key=lambda x:x[1])][::-1]

for i in range(N):
    ans=int(data_sort[i])+1
    print(ans)

Solution (Python):
N=int(input())
l=[]
for i in range(N):
    S,P=map(str,input().split())
    b=' '
    if len(S)<10:
        S=S+b*(10-len(S))
    P=(100-int(P))
    l.append([S+str(P).zfill(3),i])
l.sort()

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

Solution (Python):


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])


T_ = [D[0]]
flg = True
A = []
for i in range(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
        

if len(T_) > 0:
    T_.sort(key=lambda x:x[1], reverse=True)
    A = A + T_

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

Solution (Python):









import sys
input = sys.stdin.readline

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

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial





def solve():
    n = int(input())
    r = []
    for i in range(n):
        s, x = [x for x in input().split()]
        r.append((s, - int(x), i + 1))
    r.sort()
    for e in r:
        print(e[2])

    



t = 1

for case in range(1,t+1):
    ans = solve()


"""

"""

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

for i in range(N):
  a, b = input().split()
  L.append((a, int(b), i))
  
L.sort(key = lambda x: (x[0], -x[1]) )

for i in L:
  print(i[2]+1)

Solution (Python):
n = int(input())
l = [list(input().split()) for i in range(n)]
s,p = [list(i) for i in zip(*l)]
p = [int(i) for i in p]
z = list(set(s))
z.sort()
m = list(p)
m.sort(reverse = True)
l = []
 
k = 0
for i in range(len(z)):
    l.append(k)
    k += 200
 
o = []
for i in range(n):
    w = l[z.index(s[i])]
    w += m.index(p[i])
    o.append(w)
 
r = list(o)
r.sort()
for i in range(n):
    print(o.index(r[i]) + 1)

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_sorted = sorted(lst, key=lambda x: (x[0], -x[1], x[2]))
for _, _, num in lst_sorted:
  print(num)

Solution (Python):

q = int(input())

r = set([])

g = {}

n = {}

for i in range(q):
    s,p = input().split()
    if s not in r:
        r.add(s)
        g[s] = [int(p)]
        n[int(p)] = i+1
    else:
        g[s].append(int(p))
        n[int(p)] = i+1
        
r = list(r)

r.sort()

for i in r:
    x = g[i]
    x.sort(reverse = True)
    for t in x:
        print(n[t])

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

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


l.sort()


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

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

def main():
    n = int(input())
    res = dict()
    for i in range(n):
        s, n = input().split()
        if s in res:
            res[s].update({int(n): i+1})
        else:
            res[s] = {int(n): i+1}
    for i in sorted(res):
        for j in sorted(res[i].keys(), reverse=True):
            print(res[i][j])
    
if __name__ == '__main__':
    main()

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

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re











import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n = I()
li = []
for i in range(n):
    s,t = input().split()
    li.append([s,int(t),i+1])
li = sorted(li,key = lambda x:x[1], reverse = True)
li = sorted(li,key = lambda x:x[0])
for i in range(n):
    print(li[i][2])

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

Solution (Python):
n = int(input())
d = {}
for i in range(1,n+1):
    s, p = input().split()
    if s in d.keys():
        d[s][i] = int(p)
    else:
        d[s] = {i:int(p)}
for k, v in sorted(d.items()):
    for kk, vv in sorted(v.items(), key=lambda x: -x[1]):
        print(kk)

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

for i in sort_sp:
    print(sp.index(i)+1)

Solution (Python):
N=int(input())
data=[]
for i in range(N):
  S,P=input().split()
  P=int(P)
  data.append((S,-P,i+1))
data.sort()
for _,_,i in data:
  print(i)

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7


N = int(readline())
SP = [list(readline().split()) + [i+1] for i in range(N)]
for i in range(N):
    SP[i][1] = int(SP[i][1])
SP.sort(key=lambda x: (x[0], -x[1]))
for i in range(N):
    print(SP[i][2])

Solution (Python):




import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=[input().rstrip().split(" ") for i in range(n)]
for i in range(n):
    lis[i][1]=int(lis[i][1])
nl=[]
for i in range(n):
    nl.append([lis[i][0],lis[i][1],i])
nl.sort(key=lambda x:(x[0],-x[1]))

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

Solution (Python):
n = int(input())
spi = []
for i in range(n):
    s,p = input().split()
    spi.append([s,int(p), i+1])
spi.sort()
before = spi[0][0]
ans = [spi[0][2]]
for s,p,i in spi[1:]:
    if s == before:
        ans.append(i)
    else:
        for x in ans[::-1]:
            print(x)
        before = s
        ans = [i]
for x in ans[::-1]:
    print(x)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

N = ini()
d = []
for i in range(N):
    s, p = ins().split()
    p = int(p)
    d.append((s, -p, i + 1))
d.sort()


def solve():
    for _, _, i in d:
        print(i)


solve()

Solution (Python):
N = int(input())
data = []
ans = []
for i in range(1, N+1):
  city, score = input().split()
  score = int(score)
  data.append([city, score, i])
city_list = [x[0] for x in data]
score_list = [x[1] for x in data]
num_list = [x[2] for x in data]
city_unique = sorted(set(city_list))

for city_u in city_unique:
  city_index = [i for i, x in enumerate(city_list) if x == city_u]
  for score in sorted([score_list[x] for x in city_index], reverse=True):
    print(num_list[score_list.index(score)])

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

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

s = [list(map(str, input().split())) for _ in range(n)]
for row in s:
    row[1] = int(row[1])
ss = sorted(s)
ins = 0
ans = list()
tmp = 0
for i in ss:
    if i[0] == tmp:
        ans.insert(ins,i)
    else:
        ins = len(ans)
        ans.append(i)
        tmp = i[0]
for j in ans:
    print(s.index(j)+1)

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

Solution (Python):
N=int(input())
S=[list(map(str,input().split())) for _ in range(N)]
for row in S:
    row[1]=int(row[1])
SS=sorted(S)
ins=0
ans=list()
tmp=0
for i in SS:
    if i[0]==tmp:
        ans.insert(ins,i)
    else:
        ins=len(ans)
        ans.append(i)
        tmp=i[0]
for j in ans:
    print(S.index(j)+1)