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):
def main():
    N = int(input())
    restaurants = []
    for i in range(N):
        si, pi = input().split()
        restaurants.append([i+1, si, int(pi)])
    cities = sorted(set([restaurant[1] for restaurant in restaurants]))

    for city in cities:
        same_cities = []
        for restaurant in restaurants:
            if restaurant[1] == city:
                same_cities.append(restaurant)
        sorted_restaurants = sorted(same_cities, key=lambda restaurant: restaurant[2], reverse=True)
        [print(restaurant[0]) for restaurant in sorted_restaurants]


if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

Solution (Python):
from operator import itemgetter

N = int(input())
city_point_list = []
for i in range(N):
    c, p = input().split()
    pair = (c, int(p))
    city_point_list.append(pair)

cp_num_dict = {}
for i in range(len(city_point_list)):
    cp_num_dict[city_point_list[i]] = i + 1

point_sort_rev = sorted(city_point_list, key=itemgetter(1), reverse=True)
city_sort = sorted(point_sort_rev, key=itemgetter(0))

for cp in city_sort:
    print (cp_num_dict[cp])

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

for _, _, i in a:
    print(i + 1)

Solution (Python):
num = int(input())
guide = [[i for i in input().split()] for j in range(0, num)]
dic = 1
for i in range(0, len(guide)):
    guide[i][1] = int(guide[i][1])
    guide[i].append(dic)
    dic += 1
guide.sort(reverse=True, key=lambda x: x[1])
guide_book = sorted(guide, key=lambda x: x[0])

for i in range(0, len(guide)):
    print(guide_book[i][2])

Solution (Python):
N = int(input())
SP = [[_ for _ in input().split()] + [_ + 1] for _ in range(N)]
SP.sort(key = lambda x:(x[0],-int(x[1])))
ans = [0] * N

for i, sp in enumerate(SP):
    s, p, x = sp
    ans[i] = x

for j in ans:
    print(j)

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

for i in range(N):
    toshi, ten = map(str, input().split())
    lst.append((toshi,int(ten),i+1))

for i in range(N):
    flag = 0
    for j in range(N-1):
        if lst[j][0] > lst[j+1][0]:
            lst[j] ,lst[j+1] = lst[j+1],lst[j]
            flag = 1
    if flag == 0:break

for i in range(N):
    flag = 0
    for j in range(N-1):
        if lst[j][0] == lst[j+1][0]:
            if lst[j][1] < lst[j+1][1]:
                lst[j] ,lst[j+1] = lst[j+1],lst[j]
                flag = 1
    if flag == 0:break
for lst in lst:
    print(lst[2])

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

s_list = []
p_list = []

for _ in range(0, n):
    s, p = input().split()
    s_list.append(s)
    p_list.append(int(p))

result = list(enumerate(zip(s_list, p_list)))
result = sorted(result, key = lambda x: (x[1][0], -x[1][1]))

for i in [ x[0] + 1 for x in result ]:
    print(i)

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

R.sort()
for i in range(len(R)):
    print(R[i][2])

Solution (Python):
def solve(n, s, p):
    ids = list(range(1,n+1))
    for _, _, id in sorted(zip(s, p, ids), key=lambda _: "%s-%03d" % (_[0], 100-_[1])):
        print(id)

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

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

Solution (Python):
from sys import stdin, stdout

n = int(stdin.readline().rstrip())

l = list()

for i in range(n):
    s, p = [x for x in stdin.readline().rstrip().split()]
    l.append((s, int(p)*(-1), i + 1))
    
l.sort()
    
for i in range(n):
    print(l[i][2])

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

C = {}
for i in range(N):
  city, score = input().split(' ')
  score = int(score)
  if city not in C:
    C[city] = []
  C[city].append({'score':score,'idx':i})
  
for p in sorted(C.keys()):
  for k in sorted(C[p],key=lambda x:x['score'],reverse=True):
    print(k['idx']+1)

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




SP2 = [ [0, 0, 0] for _ in range(N) ]
for _ in range(N):
	SP2[_][0] = SP[_][0]
	SP2[_][1] = -( int(SP[_][1]) )
	SP2[_][2] = _+1

SP2.sort()

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

Solution (Python):


import sys
from operator import itemgetter

n = int( sys.stdin.readline().strip() )
rest= []
for i in range(n):
    k,v = sys.stdin.readline().strip().split()
    rest.append( [i+1,k,int(v)] )

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

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

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

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

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

for _ in range(n):
    li_w.append(input().split())

li_sorted = sorted(li_w, key=lambda x: (x[0], 100 - int(x[1])))
for a in li_sorted:
    print(li_w.index(a) + 1)

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

for key in sorted(res.keys()):
  for score, idx in sorted(res[key], reverse=-1):
    print(idx)

Solution (Python):
def main():
    N = int(input())
    SP = [list(input().split()) for i in range(N)]
    for i, SPl in enumerate(SP):
        SPl.append(i+1)
        SPl[1] = int(SPl[1])
    
    SP.sort(reverse=True, key=lambda x: x[1])
    
    SP.sort(key=lambda x: x[0])
    

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


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
rest = {}
cities = []
for i in range(N):
    k,s = input().split()
    if k not in rest:
        rest[k] = []
        cities.append(k)
    rest[k].append([int(s),i+1])
cities.sort()
for k in cities:
    rest[k].sort(reverse = True)
    for i in rest[k]:
        print(i[1])

Solution (Python):




from operator import itemgetter

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

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

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

Solution (Python):


N = int(input())

rest = {}
cities = []
for i in range(N):
    k, s = input().split()
    if k not in rest:
        rest[k] = []
        cities.append(k)
    rest[k].append([int(s), i + 1])

cities.sort()
for k in cities:
    rest[k].sort(reverse=True)
    for r in rest[k]:
        print(r[1])

Solution (Python):
from operator import itemgetter

if __name__ == '__main__':
    n = int(input())
    input_list = [input() for i in range(n)]
    restaurant_list = []
    for index, _input in enumerate(input_list):
        _restaurant_data = {'id': index + 1, 'region': _input.split()[0], 'point': int(_input.split()[1])}
        restaurant_list.append(_restaurant_data)

    restaurant_list.sort(key=itemgetter('point'), reverse=True)
    restaurant_list.sort(key=itemgetter('region'))
    for restaurant in restaurant_list:
        print(restaurant['id'])

Solution (Python):

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



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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]

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



solve()

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

Solution (Python):
n = int(input())
dic = {}
area = []
price = {}
trans = {}
modified_price = []
for i in range(n):
    [a,b] = [i for i in input().split()]
    if a not in area:
        area.append(a)
        dic[a] = [int(b)]
    else:
        dic[a].append(int(b))
    price[int(b)] = i+1
area.sort()

for i in range(len(area)):
    for j in range(len(dic[area[i]])):
        trans[dic[area[i]][j]+(len(area)-i)*1000] = dic[area[i]][j]
        modified_price.append(dic[area[i]][j] + (len(area)-i) * 1000)
modified_price.sort(reverse = True)
for i in range(len(modified_price)):
    print(price[trans[modified_price[i]]])

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

result = {}
for i in range(N):
  S, P = input().split()
  P = int(P)
  if S in result:
    result[S].append([P, i])
  else:
    result[S] = [[P, i]] 

score_sorted = sorted(result.items(), key=lambda x:x[0])

for kv in score_sorted:
  v = kv[1]
  s = sorted(v, key = lambda x: x[0], reverse=True)
  for i in s:
    print(i[1] + 1)

Solution (Python):
import numpy as np
N = int(input())
restaurants_list = []
for i in range(N):
  name,score = map(str,input().split())
  score = int(score)
  restaurants_list.append([name,score,i+1])
restaurants_list.sort(key = lambda x:x[1],reverse=True) 
restaurants_list.sort(key = lambda x:x[0]) 
for i in range(N):
  print(restaurants_list[i][2])

Solution (Python):
n=int(input())
res_list=list()
for i in range(n):
  name, score = map(str, input().split())
  ll = {"index": i, "name": name, "score": int(score)}
  res_list.append(ll)

sorted_items = sorted(
  res_list,
  key = lambda x: (x['name'], -x['score'])
)

for s in sorted_items:
  print(s['index']+1)

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

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

a = sorted(a, key=lambda x:x[2], reverse=1)
a = sorted(a, key=lambda x:x[1], reverse=0)

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    a, p = LI()
    print((a*3+p)//2)
    return


def B():
    n = II()
    sp = []
    for i in range(n):
        sp.append(input().split())
    another = [(s[0], -1 * int(s[1]),num) for num,s in enumerate(sp)]
    another.sort()
    for s,p,q in another:
        print(q+1)

    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    B()

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

s_ps = {}
for n in range(N):
    s,p=input().split()
    p=int(p)

    if s_ps.get(s) is None:s_ps[s] = []

    s_ps[s].append((n,p))

for s, ps in sorted(s_ps.items(), key=lambda x:x[0]):
    for n, p in sorted(ps, key=lambda x:x[1]*-1):
        print(n+1)

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

SP = []
for i in range(N):
    str = input().split()
    SP.append([str[0] ,int(str[1])*-1,i])

SP.sort()

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

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

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

if __name__ == '__main__':
    solve()

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

for i in range(N):
    SP[i] = [SP[i][0], int(SP[i][1]) * (-1), i+1]
SP.sort(key=lambda x: x[1])
SP.sort()

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

Solution (Python):



import sys

input = sys.stdin.readline

def main():
    N = int(input())
    cities = [[] for _ in range(N)]
    for i in range(N):
        s, p = list(input().split())
        cities[i] = [i+1, s, int(p)]
    cities.sort(key=lambda x: (x[1], 100 - x[2]))
    for c in cities:
        print(c[0])

main()

Solution (Python):
n = int(input())
rss = []
num = 1
for i in range(n):
  tmp = input().split(" ")
  tmp[1] = 100-int(tmp[1])
  tup = [tmp,num]
  rss.append(tup)
  num = num+1

rss.sort()

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

Solution (Python):
from operator import itemgetter

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

mylist=sorted(mylist,key=itemgetter(1),reverse=True)

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

for li in mylist:
    print(li[2]+1)

Solution (Python):

N = int(input())
S, P = (
    zip(*(
        (s, int(p))
        for s, p in (input().split() for _ in range(N))
    )) if N else
    ((), ())
)

ans = '\n'.join(
    str(i)
    for _, _, i in sorted(
        zip(
            S,
            P,
            range(1, N + 1)
        ),
        key=lambda t: (t[0], -t[1])
    )
)


print(ans)

Solution (Python):
N=int(input())
book1={}
for i in range(1,N+1):
    string,point=input().split()
    point=int(point)
    if  string in book1.keys():
        book1[string][point]=i
    else:
        book1[string]={point:i}
for keys in sorted(book1.keys()):
    for point in sorted(book1[keys].keys(),reverse=True):
        print(book1[keys][point])

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

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

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

list = []
for i in range(N):
    s, p = input().split()
    P = 100 - int(p)
    list.append((s,P,i+1))

list.sort()

for a in list:
    print(a[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()
for t in SP:
    print(t[2])

Solution (Python):
def main():
	N = int(input())
	restaurants = []
	for i in range(N):
		S, P = input().split()
		p = int(P)
		restaurants.append([S, p, i+1])
	restaurants.sort(key=lambda x: (x[0], -x[1]))

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


if __name__ == '__main__':
	main()

Solution (Python):
def resolve():
    n = int(input())
    rests = []
    for i in range(1, n+1):
        o = input().split(" ")
        o[1] = (0 - int(o[1]))
        o.append(i)
        rests.append(o)

    rests = sorted(rests, key=lambda x: (x[0], x[1]))
    for i in range(n):
        print(rests[i][2])
    
if '__main__' == __name__:
    resolve()

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

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

nums.sort(key=lambda x: int(x[2]))
nums.reverse()
nums.sort(key=lambda x: x[1])


for elem in nums:
    print(elem[0])

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

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

l.sort(key=lambda x:(x[1], -int(x[2])))
for i,s,p in l:
  print(i+1)

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

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

sps = sorted(sps,key=lambda sp: (sp[1],-sp[2]))

for sp in sps:
    print(sp[0])

Solution (Python):
from operator import itemgetter
n = int(input())
l = []
for _ in range(n):
  s,p = map(str,input().split())
  p = int(p)
  l.append([s,p])

l1 = sorted(l,key=itemgetter(1),reverse=True)

l2 = sorted(l1,key=itemgetter(0))

for i in l2:
  print(l.index(i)+1)

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

Solution (Python):
N=input()
N=int(N)
S=[100]*N
P=[100]*N
for num in range(N):
    S[num]=input().split()
    S[num].append(num+1)
    S[num][1]=int(S[num][1])

S.sort()
flag=0
flag2=0
while(flag==0):
    flag2=0
    for num in range(0,N-1):
        if(S[num][0]==S[num+1][0]):
            if(S[num][1]<S[num+1][1]):
                S[num],S[num+1]=S[num+1],S[num]
                flag2=1
    if(flag2==0):
        flag=1
    
            

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

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

SP.sort()

while SP:
    restaurant = SP.pop(0)
    city = restaurant[0]
    point_num = [[restaurant[1], restaurant[2]]]
    while SP and SP[0][0] == city:
        restaurant = SP.pop(0)
        point_num.append([restaurant[1], restaurant[2]])

    point_num.sort(reverse=True)
    for i in point_num:
        print(i[1])

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

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

for i in range(n):
    S,P=input().split()
    spi+=[[S,int(P),i+1]]
spi.sort()
city=spi[0][0]
citys=[]
ans=[]
for s,p,i in spi:
    if city==s:
        citys+=[[p,i]]

    else:
        citys.sort(reverse=True)
        for x,y in citys:
            ans+=[y]

        city=s
        citys=[[p,i]]

citys.sort(reverse=True)
for x,y in citys:
    ans+=[y]

for i in ans:print(i)

Solution (Python):
inputNum = int(input())
shop = [0] * inputNum

for num in range(inputNum):
    city, score = input().split(" ")
    shop[num] = {'ID' : num + 1, 'City' : city, 'Score' : score}

sort_shop = sorted(shop, key = lambda x:-int(x['Score']))
sort_shop =sorted(sort_shop, key = lambda x:x['City']) 

for answer in sort_shop:
    print(answer['ID'])

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 i in l:
	print(i[0])

Solution (Python):
from operator import itemgetter

def input_list(num,args):
    for i in range(num):
        S,P = input().split()
        P=int(P)
        if 1<=len(S)<=10 and S.islower()==1 and S.isalpha()==1 \
           and 0<=P<=100 and isinstance(P,int)==1:
            args.append([S,P])
        else :
            print("ERROR")
            exit()



def sort_list(*args):
    tmp=sorted(args,key=itemgetter(1),reverse=1)
    dict_sorted=sorted(tmp,key=itemgetter(0))

    return dict_sorted


def check_list(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    if len(seq) != len(unique_list):
        print("ERORR")
        exit()
    
    



def main():
    
    

    num=int(input())
    if 1<=num<=100:
        
        restaurant=[]
        input_list(num,restaurant)

        check_list(restaurant)

        
        restaurant_sorted=sort_list(*restaurant)

        for i in range(num):
            for j in range(num):
                if restaurant_sorted[i][1]==restaurant[j][1]:
                    print(j+1)
    else :
        print("ERORR")
        exit()

if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict

res_dic = defaultdict(list)

num = input()

for i in range(int(num)):
    s = input()
    lis = s.split()
    res_dic[lis[0]].append([i+1, int(lis[1])])

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

for k, l in res_dic:
    ls = sorted(l, key=lambda x:-x[1])
    for id, v in ls:
        print(id)

Solution (Python):

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

Solution (Python):

import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    sp = sorted(
        [(s, p, index) for (s, p, index) in zip(S, P, range(1, N + 1))],
        key=lambda x: (x[0], -x[1]),
    )
    for s, p, index in sp:
        print(index)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [str()] * (N)  
    P = [int()] * (N)  
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)


if __name__ == "__main__":
    main()

Solution (Python):

import numpy

N = int(input())

scores = {}
indexes = {}
for i in range(N):
    s, p = input().split()
    p = int(p)
    if s in scores:
        scores[s].append(p)
        indexes[s].append(i)
    else:
        scores[s] = [p]
        indexes[s] = [i]








for s in sorted(scores.keys()):
    for i in numpy.argsort(scores[s])[::-1]:
        print(indexes[s][i]+1)

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

Solution (Python):
N = int(input())
restaurants = list()
for i in range(1, N+1) :
    s, p = input().split()
    r = { 'i' : i, 's' : s, 'p' : int(p) }
    restaurants.append(r)

restaurants.sort(key=lambda r : (r['s'], -r['p']))

for r in restaurants :
    print(r['i'])

Solution (Python):
n = int(input())
S = []
count = [0] * n
for i in range(n):
    a, b = input().split()
    S.append([a, -int(b), i + 1])

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

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

Solution (Python):
N = int(input())
SP = []
for i in range(N):
    S,P = input().split()
    P = int(P)
    SP.append([S,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())
lst = []
for i in range(N):
  data = input().split(" ")
  lst.append([data[0], -int(data[1]), i+1])
 
s = sorted(lst, key = lambda x: (x[0], x[1]))
 
for i in s:
  print(i[2])

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

X.sort()
for S, P, i in X:
    print(i)

Solution (Python):
from __future__ import print_function


import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)






























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

if __name__ == '__main__':
    main()

Solution (Python):
from __future__ import print_function


import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)






























def main():
    n = int(input())
    l=[["",0,0] for i in range(n)]
    
    for i in range(n):
        s,m=input().split()
        m=-int(m)
        l[i][0]=s
        l[i][1]=m
        l[i][2]=i+1
    
    l.sort()
    
    for x in l:
        print(x[2])

if __name__ == '__main__':
    main()

Solution (Python):
from __future__ import print_function


import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from queue import PriorityQueue as pq



import random


def main():
    n = int(input())
    l=[["",0,0] for i in range(n)]
    
    for i in range(n):
        s,m=input().split()
        m=-int(m)
        l[i][0]=s
        l[i][1]=m
        l[i][2]=i+1
    
    l.sort()
    
    for x in l:
        print(x[2])

if __name__ == '__main__':
    main()

Solution (Python):
from __future__ import print_function


import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
def lcm(n,m):
    return int(n*m/gcd(n,m))

import re
import array
import copy
import functools
import operator

import collections
import itertools
import bisect
import heapq


from heapq import heappush
from heapq import heappop
from queue import PriorityQueue as pq



import random


def main():
    n = int(input())
    l=[["",0,0] for i in range(n)]
    eprint(l)
    for i in range(n):
        s,m=input().split()
        m=-int(m)
        l[i][0]=s
        l[i][1]=m
        l[i][2]=i+1
    eprint(l)
    l.sort()
    eprint(l)
    for x in l:
        print(x[2])

if __name__ == '__main__':
    main()

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

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

rank_list = []

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

rank_list.sort()

for rank in rank_list:
    print(rank[2])

Solution (Python):
from __future__ import print_function


import sys
input = sys.stdin.readline

def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)




























from queue import PriorityQueue as pq




    
    

    
    
    
    

def main():
    n = int(input())
    dict={}
    for i in range(1,n+1):
        str_x,num = input().split()
        num =int(num)
        if (str_x in dict):
            dict[str_x].put((-num,i))
            
        else:
            a=pq()
            dict[str_x]=a
            dict[str_x].put((-num,i))
            
    eprint(dict)
    ll = sorted(list(dict.items()))
    eprint(ll)
    
    
    
    for item in ll:
        while item[1].qsize():
            print((item[1].get())[1])
if __name__ == '__main__':
    main()

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

for _ in range(n):
    sp.append(input().split())

for i in sp:
    i[1]=-int(i[1])
    
    i.append(sp.index(i))
    

sp.sort()

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

Solution (Python):

import os
import time
import re
import math


N = int(input())
SP=[]
for a in range(N):
    temp=input().split()
    SP.append([temp[0],int(temp[1]),(a+1)])

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

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

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


ans = []
index = {}
for i, _ in enumerate(range(N)):
    S, P = input().split()
    ans.append((S, P))
    index[(S, P)] = i + 1

for (S, P) in sorted(ans, key=lambda x: (x[0], -int(x[1]))):
    print(index[(S, P)])

Solution (Python):
N = int(input())
dict = {}
for i in range(N):
  list = input().split()
  list[1] = str(int(list[1]) * -1 + 200)
  dict[' '.join(list)] = i
for k, v in sorted(dict.items()):
  print(v + 1)

Solution (Python):


n = int(input())

a = list()

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


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

Solution (Python):
from collections import defaultdict

N = int(input())
di = defaultdict(list)

for n in range(1, N + 1):
    S, P = input().split()
    P = int(P)
    di[S].append({n: P})

li = sorted(di.items(), key=lambda x: x[0])

di2 = {}

for tu in li:
    for mini_dict in tu[1]:
        for k, v in mini_dict.items():
            di2[k] = v
    sorted_di2 = sorted(di2.items(), key=lambda x: x[1], reverse=True)
    for tup2 in sorted_di2:
        print(tup2[0])

    sorted_di2 = []
    di2 = {}