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):
from sys import stdin
def I(): return int(stdin.readline().rstrip())
def LS(): return list(stdin.readline().rstrip().split())

n = I()
info = []
for i in range(n):
    tmp = LS()
    l = []
    l.append(i+1)
    l.append(tmp.pop(0))
    l.append(tmp.pop(0))
    info.append(l)


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

for i in range(n):
    print(info[i][0])

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

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())
NSI = [input().split() + [i + 1] for i in range(n)]
NSI.sort(key=lambda x:(x[0], -int(x[1])))
for _, _, i in NSI:
	print(i)

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

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

for k,v in enumerate(sp_sorted):
  print(sp.index(v)+1)

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)








n=n0()
s=s3(n)
[s[i].append(i+1) for i in range(n)]

s.sort(key=lambda x:(x[0],-1*int(x[1])))

[print(x[2]) for x in s]

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


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

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

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

Solution (Python):

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

Solution (Python):
from collections import defaultdict


def main():
    N = int(input())
    restaurant = defaultdict(list)
    for i in range(N):
        tmp = input().split()
        restaurant[tmp[0]].append((int(tmp[1]), i+1))

    name_list = sorted(list(restaurant.keys()))

    for n in name_list:
        tmp = sorted(restaurant[n], key=lambda x: x[0], reverse=True)
        for t in tmp:
            print(t[1])


if __name__ == "__main__":
    main()

Solution (Python):



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


if __name__ == '__main__':
    main()

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

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

LS = sorted(L)

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

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


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



for s, p, i in s_p_list:
    print(i)

Solution (Python):
N = int(input())
R_L = []
for n in range(N):
    S,P = input().split()
    R_L.append([S,int(P)])

R_L2 = R_L.copy()
R_L2.sort( key=lambda x:(x[0],-x[1]))
for r in R_L2:
    print(R_L.index(r)+1)

Solution (Python):
N = int(input())
R_L = []
for n in range(N):
    S,P = input().split()
    R_L.append([S,int(P)])

R_L2 = R_L.copy()
R_L2.sort( key=lambda x:(x[0],-x[1]))
for r in R_L2:
    print(R_L.index(r)+1)

Solution (Python):
def inp():
    return(int(input()))


def invr():
    return(map(str, input().split()))


N = inp()
pos = [0] * 101
SP = dict()
for i in range(1, N+1):
    key, val = invr()
    val = int(val)
    if key in SP:
        temparr = SP[key]
        temparr.append(val)
        SP[key] = temparr
    else:
        SP[key] = [val]
    pos[val] = i

names = sorted(SP)

for key in names:
    values = SP[key]
    values = sorted(values, reverse=True)
    for i in values:

        print(pos[i])

Solution (Python):
n=int(input())
ans=[]
for i in range(n):
    key,value=input().split()
    ans.append([key,int(value),i+1])
ans.sort(key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(ans[i][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())
result = []
for i in range(N):
  n = input().split()
  city = n[0]
  point = int(n[1])
  result.append([city, point, i])
result.sort(key=lambda x:(x[0], -x[1]))
[print(i[2]+1) for i in result]

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):
import sys

input = sys.stdin.readline

def main():
    ans = 0
    N = int(input())
    sl = [input().split() + [i+1] for i in range(N)]
    sl.sort(key=lambda x: (x[0], -int(x[1])))
    for i in sl:
        print(i[2])

if __name__ == '__main__':
    main()

Solution (Python):
from operator import itemgetter
n = int(input())
l = []

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

l2 = sorted(l, key=itemgetter(1), reverse=True)
l2 = sorted(l2, key=itemgetter(0))

for i in l2:
    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])
sp1 = sorted(sp, key = lambda x: (x[0], -1*x[1]))
for i in range(N):
  print(sp1[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[1], reverse=True)
SP.sort(key=lambda x: x[0])

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

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

Solution (Python):
from operator import itemgetter, attrgetter
n = int(input())
s = [input().split() for i in range(n)]
ss = []
ll = []
l = []
for i in range(0, n):
  l.insert(i, [s[i][0], int(s[i][1]), i+1])
ss = sorted(l, key=itemgetter(1), reverse=True)
ll = sorted(ss, key=itemgetter(0))
for i in ll:
  print(i[2])

Solution (Python):
N = int(input())
sp_list = []
sorted_list = []
for i in range(N):
  S,P = map(str, input().split(' '))
  sorted_list.append([S,int(P)])
  sp_list.append(S + ' ' + P)
sorted_list = sorted(sorted_list, key=lambda x:(x[1]), reverse=True)
sorted_list = sorted(sorted_list, key=lambda x:(x[0]))

for i in range(N):
  count=1
  for j in range(N):    
    if sorted_list[i][0]+' '+str(sorted_list[i][1]) ==sp_list[j]:
      print(count)
      break
    count+=1

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

Solution (Python):
N = int(input())
NSP = [[i] + input().split() for i in range(1,N+1)]
M = {}
for nsp in NSP:
    if nsp[1] in M:
        M[nsp[1]].append(nsp)
    else:
        M[nsp[1]] = []
        M[nsp[1]].append(nsp)
for m in sorted(M):
    m2 = sorted(M[m], key=lambda x: -int(x[2]))
    for m3 in m2:
        print(m3[0])

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

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

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

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

ans = sorted(s, key=lambda x: (x[0], -x[1]))
for x, y, a in ans:
    print(a)

Solution (Python):
n = int(input())
data = dict()
name = set()
for i in range(n):
    s, p = input().split()
    p = int(p)
    if s in data:
        data[s].append([p, i + 1])
    else:
        data[s] = []
        data[s].append([p, i + 1])
    name.add(s)
name = list(name)
name.sort()
for n in name:
    data[n].sort(reverse = True)
    for i in data[n]:
        print(i[1])

Solution (Python):
def main():
    n = int(input())
    a = [None]*n
    for i in range(n):
        s, p = map(str, input().split())
        p = int(p)
        p *= -1
        a[i] = [s, p, i+1]
    a.sort(key=lambda x: (x[0], x[1]))
    for i in range(n):
        print(a[i][2])

if __name__ == "__main__":
    main()

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

for i in range(n):
    sp.append(input().split())
    sp[i].append(i + 1)

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

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

Solution (Python):

N = int(input())
page = []
p_append = page.append
for n in range(1, N + 1):
    S, P = map(str, input().split())
    p_append(
        {
            "number": n,
            "city": S,
            "point": int(P)
        }
    )


page = sorted(page, key=lambda x: x["point"], reverse=True)
page = sorted(page, key=lambda x: x["city"])
for p in page:
    print(p["number"])

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

Solution (Python):
n = int(input())
s = set()       
a = []          
b = dict()          
c = []          

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

s = list(s)
s.sort()

for j in range(len(s)):
    b = dict()
    for k in range(n):
        if a[k][0] == s[j]:
            b[a[k][2]] = a[k][1]
    x = sorted(b.items(),key=lambda x:x[1],reverse=True)
    for l in range(len(x)):
        c.append(x[l][0])

for m in range(len(c)):
    print(c[m])

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[1], reverse=True)
sp.sort(key=lambda x: x[0])
for i in range(n):
    print(sp[i][2])

Solution (Python):
N=int(input())
data=[]
for i in range(N):
    d=list(input().split())
    d[1]=int(d[1])
    d.append(i+1)
    data.append(d)
data.sort()
mem=[]; current=''
ans=[]
for i in data:
    if current!=i[0]:
        current=i[0]
        mem.sort(key=lambda x:x[1])
        d=[0]*len(mem)
        for j in range(len(mem)): d[len(mem)-(j+1)]=mem[j][2]
        ans.extend(d)
        mem=[i]
    else: mem.append(i)
mem.sort(key=lambda x:x[1])
d=[0]*len(mem)
for j in range(len(mem)): d[len(mem)-(j+1)]=mem[j][2]
ans.extend(d)
mem=[i]
for i in ans: print(i)

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


from collections import defaultdict
sp = defaultdict(lambda: [])
town=set([])

for i in range(1,n+1):
    s,p=map(str,input().split())
    town.add(s)
    sp[s].append((int(p),i))
town=list(town)
town.sort()
for item in town:
    tmp=sp[item]
    tmp.sort(reverse=True)
    for t in tmp:
        print(t[1])

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

Solution (Python):
def main():
    N=int(input())
    RDictionary={}
    index=1
    for i in range(N):
        SP=input().split()
        S=SP[0]
        P=int(SP[1])
        if (S in RDictionary.keys()):
            RDictionary[S].append((P,index))
        else:
            RDictionary[S]=[(P,index)]
        index+=1

    Names=list(RDictionary.keys())
    Restaurants=list(RDictionary.values())

    Rest_Town=zip(Names,Restaurants)

    Rest_Town=sorted(Rest_Town)

    Names,Restaurants=zip(*Rest_Town)
    Restaurants=list(Restaurants)

    

    for i in range(len(Restaurants)):
        Restaurants[i]=sorted(Restaurants[i],reverse=True)

    for town in Restaurants:
        for rest in town:
            print(rest[1])


if __name__=="__main__":
    main()

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])
  sp[i].append(i+1)
sp.sort(key=lambda x: (x[0],x[1]))
for i in range(n):
  print(sp[i][2])

Solution (Python):
n=int(input())
sps=dict()
for i in range(n):
    s,p=input().split()
    if not s in sps:
        sps[s]=[]
    sps[s].append([int(p),i+1])
for k in sorted(list(sps.keys())):
    for _,v in sorted(sps[k], reverse=True):
        print(v)

Solution (Python):
n = int(input())
d = []
for i in range(n):
    a,b = map(str,input().split())
    b = -int(b)
    d.append([a,b,i])
d.sort()
for i in range(n):
  print(d[i][2]+1)

Solution (Python):
n = int(input())
d = []
for i in range(1,n+1):
    city, score = input().split()
    d.append({'id':i, 'restaurant':{'city':city, 'score':int(score)}})

sorted_d = sorted(
    d,
    key = lambda x: (x['restaurant']['city'], -x['restaurant']['score'])
)

for l in sorted_d:
    print (l['id'])

Solution (Python):
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import sys
sys.setrecursionlimit(10**6)




input_list = lambda : list(map(int,input().split()))

n=int(input())

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

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

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

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

rests.sort(key=lambda x: x[0]+chr(100-x[1]))
for rest in rests:
    print(rest[2])

Solution (Python):
N = int(input())
rests = {}
cities = []
lst = []

for i in range(N):
    S, P = input().split()
    cities.append(S)
    lst.append((S, int(P)))
    try:
        rests[S].append(int(P))
        rests[S].sort()
    except KeyError:
        rests[S] = [int(P)]

cities.sort()
order = [(city, rests[city].pop()) for city in cities]

for rest in order:
    print(lst.index(rest) + 1)

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

SP.sort()

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

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

Solution (Python):
N = int(input())
SP = [None] * N
for i in range(N):
    SP[i] = input().split()
    SP[i][1] = int(SP[i][1]) * -1

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

S = sorted(SP)

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

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[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,reverse=True,key=lambda x:x[1])
l = sorted(l, key=lambda x:x[0])
 
for i in range(n):
    print(l[i][-1])

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

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

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

Solution (Python):
n=int(input())
a=[[""]*3 for ii in range(n)]
for ii in range(n):
  s=input().split()
  
  a[ii][0]=s[0]
  a[ii][1]=100-int(s[1])
  a[ii][2]=ii
a.sort()
for ii in range(n):
  print(a[ii][2]+1)

Solution (Python):
import itertools
import math
import fractions
import functools
import copy

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

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

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

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

Solution (Python):
n = int(input())
s =[]
p = []
for _ in range(n):
    si, pi = input().split()
    s.append(si)
    p.append(int(pi))
s_ord = sorted(list(set(s)))
for c in s_ord:
    ind = [i for i, x in enumerate(s) if x == c]
    p_ord = sorted([point for num, point in enumerate(p) if num in ind], reverse = True)
    for r in p_ord:
        print(p.index(r) + 1)

Solution (Python):

n=int(input())

sp=[]
for i in range(n):
    a=list(map(str,input().split()))
    a.append(i+1)
    sp.append(a)
    
sp=sorted(sp,key=lambda x:int(x[1]),reverse=True)
sp=sorted(sp,key=lambda x:x[0])

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

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

sp = []
for i in range(N):
  sp.append(list(map(str,input().split()))+[i+1])
  
sp.sort(key=lambda x:(x[0],-int(x[1])))
for i in range(N):
  print(sp[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_sorted = sorted(l, key = lambda x: (x[0], -x[1]))
for j in range(n):
    print(l_sorted[j][2])

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

Solution (Python):
from collections import Counter
N = int(input())
A = []
B = []
E = []
for i in range(N):
  l = list(input().split())
  l[1] = int(l[1])
  A.append(l)
  B.append(l[0])
  E.append(l[1])
A.sort()
C = Counter(B)
C = sorted(C.items(), key=lambda x:x[0])
cnt = 0
for c in C:
  c = c[1]
  D = reversed(A[cnt:cnt+c])
  cnt += c
  for d in D:
    print(E.index(d[1])+1)

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


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

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

for out in ss_sorted:
    print(out[2] + 1)

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

Solution (Python):

N = int(input())
Shop_List=[]
for i in range(N):
    Temp_List=list(input().split())
    Temp_List[1]=int(Temp_List[1])
    Temp_List.append(i+1)
    Shop_List.append(Temp_List)


Shop_List_Sorted = sorted(Shop_List, key=lambda x:(x[0], -x[1]))
for k in range(N):
    print(Shop_List_Sorted[k][2])

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

ss = dict()
sss = dict()
for i in range(N):
    s, p = input().split()
    sss[s, p] = i + 1
    if s in ss:
        ss[s] = ss[s] + ',' + p
    else:
        ss[s] = p

ss_sorted = sorted(ss.items())

for tmp_ss in ss_sorted:
    s = tmp_ss[0]
    ps = list(map(int, tmp_ss[1].split(',')))
    ps.sort(reverse=True)
    for p in ps:
        print(sss[s, str(p)])

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

N = int(readline())
rest = [None] * N
for i in range(N):
  s,p = readline().split()
  rest[i] = [s,int(p),i + 1]
  
rest = sorted(rest, key = lambda x:(x[0],-x[1]))
for r in rest:
  print(r[2])

Solution (Python):






import sys
input = sys.stdin.readline

import math
import bisect
from collections import deque
from fractions import gcd
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


def lcm(a, b):
    return a * b // gcd (a, b)


def bit_count(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count





N = inputI()
data = inputSLL(N)

dic = {}
for i in range(N):
  c,p = data[i]
  if c not in dic:
    dic[c] = [(int(p),i)]
  else:
    dic[c].append((int(p),i))
    
key = [k for k in dic]
key.sort()
for k in key:
  dic[k].sort(reverse=True)
  for p,i in dic[k]:
    print(i+1)

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

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

for i in range(N):
    sp[i].append(i+1)

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

city = []
for k in range(N):
    if sp[k][0] not in city:
        city.append(sp[k][0])

A = []
for i in range(len(city)):
    cnt = 0
    end = 0
    for j in range(i,N):
        if sp[j][0] == city[i]:
            cnt += 1
            end = j
    A.append((cnt,end+1-cnt))

B = [0] * len(A)
for i in range(len(A)):
    begin = A[i][1]
    end = A[i][0]+A[i][1]
    B[i] = sp[begin:end]

for k in B:
    k.sort(key=lambda x:int(x[1]))
    for i in range(len(k)):
        print(k[len(k)-i-1][2])

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

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

l.sort(key = lambda l:(l[0],-l[1]))
for j in range(n):
  print(l[j][2])

Solution (Python):
n = int(input())
L = [input().split() for _ in range(n)]
d = {}
for s, p in L:
    if s not in d.keys():
        d[s] = [int(p)]
    else:
        d[s].append(int(p))
for i, v in enumerate(L, start=1):
    v.append(i)
for i in sorted(d):
    for j in sorted(d[i], reverse=True):
        for k in range(n):
            if L[k][1] == str(d[i][d[i].index(j)]):
                print(L[k][2])

Solution (Python):
N = int(input())
SP = [input().split() for _ in range(N)]
for k in range(N):
  City = "zzzzzzzzzzzzzz"
  Point = 0
  Num = 0
  for i in range(len(SP)):
    if SP[i][0] < City:
      City = SP[i][0]
  for j in range(len(SP)):
    if SP[j][0] == City and int(SP[j][1]) >= Point:
      Point = int(SP[j][1])
      Num = j
  print(Num+1)
  SP[Num][0] = "zzzzzzzzzzzzzzzzz"
  SP[Num][1] = 0

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

Solution (Python):
def main():
    N = int(input())
    book = [input().split() for i in range(N)]
    for i, j in enumerate(book):
        j[1] = int(j[1])
        j.append(i + 1)

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

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


if __name__ == "__main__":
    main()

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

for list in sp:
    list[1]= -int(list[1])
sp.sort()

for s, p, num in sp:
    print(num)

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

t = []
for i in range(1,n+1):
  s,p = tuple(input().split())
  p = int(p)
  t.append((s,p,i))
t = sorted(t,key = lambda a:a[1],reverse=True)
t = sorted(t,key = lambda a:a[0])

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

Solution (Python):
from operator import itemgetter

N = int(input())

splist = [[0, 0, 0]]*N

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

s1splist = sorted(splist, key=itemgetter(1), reverse=True)
s2splist = sorted(s1splist, key=itemgetter(0))

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

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

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

sorted_res= sorted(restrante, key = lambda x:(x[1]), reverse=True)
sorted_ans = sorted(sorted_res, key = lambda x:(x[0]))

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

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

score = {}

for i in range(n):
    s, p = input().split()

    if s not in score:
        score[s] = []

    t = [i+1,int(p)]
    score[s].append(t)

city = sorted(score)
for key in city:
    score[key] = sorted(score[key], key=lambda x: x[1], reverse=True)

    for i in range(len(score[key])):
        print(score[key][i][0])

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, reverse=True, key=lambda x:x[1])

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

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

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from collections import Counter
def resolve():
    N=int(input())
    A=[]
    for i in range(N):
        S,P=pin(str)
        P=int(P)
        A.append((S,P,i+1))
    A.sort(key=lambda x:x[1],reverse=True)
    A.sort(key=lambda x:x[0])
    for a in A:
        print(a[2])


resolve()

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

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

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

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

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

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

for k in range(N):
  print(L[k][2]+1)

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

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

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

for n in restaurant:
    print(n[2]+1)

Solution (Python):

n = int(input())

sp = [list(input().split()) for i in range(n)]
for i in range(n):
    sp[i].append(i + 1)

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

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

Solution (Python):
N = int(input())
S = [None]*N
P = [None]*N

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

P = [int(p) for p in P]
I = [j+1 for j in range(N)]
x = [(s, p, i) for s, p, i in zip(S, P, I)]

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

for s, p, i in x:
    print(i)

Solution (Python):
from operator import itemgetter
n = int(input())
s = []
p = []
b = []
cnt = 1
while True:
  try:
    ts,tp = map(str,input().split())
    s.append(ts)
    p.append(int(tp))
    b.append((ts,int(tp),cnt))
    cnt +=1
  except:
    break

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    DIC = [[]]*N
    for i in range(N):
        name, score = input().split()
        DIC[i] = [name, int(score)*-1, i]
    sDIC = sorted(DIC)

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

if __name__ == '__main__':
    main()