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

import sys
import math
from collections import defaultdict


sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]


mod = 10**9 + 7


def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))



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

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

Solution (Python):
n = int(input())
lst = []
for i in range(n):
    l = input().split()
    lst.append([l[0], int(l[1]), i+1])
sorted_lst = sorted(lst, reverse=True)
while sorted_lst != []:
    p = sorted_lst.pop()
    temp = []
    while sorted_lst != [] and p[0] == sorted_lst[-1][0]:
        temp.append(sorted_lst.pop())
    while temp != []:
        print(temp.pop()[2])
    print(p[2])

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

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

for j in range(n):
    print(score[j][2])

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

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

SP = sorted(sp)
for j in range(N):
    print(SP[j][2]+1)

Solution (Python):
n = int(input())
a = [list(input().split()) for i in range(n)]
d = sorted(set([i[0] for i in a]))
for i in a:
  for j in range(len(d)):
    if i[0] == d[j]:
      i[0] = 10000**(len(d)-(j+1))
c = [i[0]*int(i[1]) if int(i[1]) != 0 else i[0]*0.1 for i in a ]
e = sorted(c,reverse=True)
for i in e:
  print(c.index(i)+1)

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

class Restaurant:
    def __init__(self,number,name,point):
        self.number=number
        self.name=name
        self.point=point
    def __lt__(self,other):
        if self.name<other.name:
            return True
        if self.name==other.name:
            if self.point>other.point:
                return True
        return False
    def __gt__(self,other):
        if self.name>other.name:
            return True
        if self.name==other.name:
            if self.point<other.point:
                return True
        return False
    
    
restaurantlist=[]
number=1
for i in range(n):
    name,point=input().split()
    point=int(point)
    restaurant=Restaurant(number,name,point)
    number+=1
    restaurantlist.append(restaurant)
    
restaurantlist.sort()
for i in restaurantlist:
    print(i.number)

Solution (Python):
from functools import cmp_to_key
def cmp(x, y):
  if x[0] < y[0]:
    return -1
  elif x[0] > y[0]:
    return 1
  else:
    return int(y[1]) - int(x[1])
n = int(input())
d = [input().split() for _ in range(n)]
for i in range(n):
  d[i].append(i + 1)
d.sort(key = cmp_to_key(cmp))
for i in range(n):
  print(d[i][2])

Solution (Python):
n = int(input().split()[0])

point_list = []

for i in range(n):
    r, p = list(map(str, input().split()))
    data = dict(index=i+1, city=r, point=int(p))
    point_list.append(data)

sorted_list = sorted(point_list, key=lambda x: (x['city'], -x['point']))

for data in sorted_list:
    print(data['index'])

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 _, _, i in SP:
    print(i)

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

graph = {}
for i in range(1, n+1):
    s, p = input().split(' ')
    newMap = {'number': i, 'score': int(p)}
    if s not in graph:
        graph[s] = [newMap]
    else:
        graph[s].append(newMap)

keys = list(graph.keys())
keys.sort()
for key in keys:
    maps = sorted(graph[key], reverse=True, key=lambda x: x['score'])
    for map in maps:
        print(map['number'])

Solution (Python):
n = int(input())
x = []
for _ in range(n):
  x.append(input().split())
y = sorted(x)

for i in range(n):
  y[i][1] = 100 - int(y[i][1])
y.sort()
for i in range(n):
  y[i][1] = str(100 - y[i][1])
  print(x.index(y[i])+1)

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

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

for ans in arr:
  print(ans[0])

Solution (Python):
import math
import copy

class Score:
    def set_data(self, town, score, idx):
        self.town = set_town
        self.score = set_score
        self.idx = set_idx

inputa = input().split()


a = int(inputa[0])











inputList=[]
for i in range(a):
    inputItem = input().split()
    inputItem.append(i+1)
    inputList.append(inputItem)





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

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

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

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

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

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

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

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

x=list(input().split() for _ in range(n))

for i in range(n):
	x[i][1]=int(x[i][1])
	x[i].append(i)
    
y=sorted(x,key=lambda a:(a[0],-a[1]))

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

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

Solution (Python):
n=int(input())
rest=[0]*n
for i in range(n):
  a,b=map(str,input().split())
  b=int(b)
  rest[i]=[i+1,a,b]


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



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

Solution (Python):

N = int(input())
tmp = []
ans = []

for i in range(N):
	a, b = input().split()
	tmp.append(list((i + 1, a, int(b))))
	
ans = sorted(tmp, key = lambda x:(x[1], -x[2]))

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

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

data.sort()

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

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

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

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

spn=[[(s,-int(p)) for s,p in[input().split()]]+[i+1] for i in range(N)]
spn.sort()

for a,b in spn:
	print(b)

Solution (Python):
n = int(input())
d = {}
for idx in range(n):
    i = input().split()
    m = i[0]
    s = int(i[1])
    if m in d:
        d[i[0]].append((s, idx+1))
    else:
        d[i[0]] = [(s, idx+1)]

for k in sorted(d.keys()):
    for i in sorted(d[k], reverse=True):
        print(i[1])

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

Solution (Python):
N = int(input())
guide = [[0]] * N

for i in range(N):
  guide[i]= [i + 1]
  guide[i] += input().split()
  guide[i][2] = int(guide[i][2])

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

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

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

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

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

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

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

Solution (Python):
from operator import itemgetter
N=int(input())
a=[]
for i in range(N):
  p,q=input().split()
  s=int(q)
  P=[p,-s,i+1]
  a.append(P)
A=sorted(a)
      
for n in range(N):
  print(A[n][2])

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

lst = []
for i in range(N):
    s, P = map(str, input().split(" "))
    lst.append((s, -int(P), i))

lst.sort(key=lambda x: (x[0], x[1]))
for s, p, i in lst:
    print(i + 1)

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

Solution (Python):


def main():
    N = int(input())
    d = [[] for _ in range(N)]

    for i in range(N):
        city, score = input().split()
        d[i] = [i+1, city, int(score)]

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

    for item in d:
        print(item[0])

if __name__ == '__main__':
    main()

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

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

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


if __name__ == "__main__":
    solve()

Solution (Python):
n = int(input())
rest = [[i+1] + input().split() for i in range(n)]
rest = sorted(rest, key=lambda r: r[1] + str(100-int(r[2])).zfill(3))
for i in range(n):
    print(rest[i][0])

Solution (Python):
from collections import defaultdict
n = int(input())
book = defaultdict(lambda : defaultdict(int))
for i in range(n):
    s, p = input().split()
    p = int(p)
    book[s][p] = i

for _, v in sorted(book.items()):
    for _, vv in sorted(v.items(), reverse=True):
        print(vv+1)

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):
n = int(input())

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

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

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

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

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

for t in res:
    print(t[1]+1)

Solution (Python):
n = int(input())
sp = list(list(map(str,input().split())) + [i+1] for i in range(n))
sp.sort(key=lambda x: int(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())

q=[input().split() + [i] for i in range(n)]
for i in range(n):
    q[i][1]=int(q[i][1])
p=sorted(sorted( q ,key=lambda x:x[1],reverse=1),key=lambda x:x[0])
for s,t,r in p:
    print(r+1)

Solution (Python):


N = int(input())
str_list = [input() for x in range(N)]
str_sort = sorted(str_list, key=lambda x: int(x.split()[1]), reverse=True)
str_sort2 = sorted(str_sort, key=lambda x: x.split()[0])

for x in str_sort2:
    print(str_list.index(x)+1)

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

lst = [list(map(str, input().split())) + [s + 1] for s in range(N)]

all = []
for l in lst:
    l[1] = int(l[1])
    all.append(l)

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

for l in lst:
    print(int(l[2]))

Solution (Python):
n = int(input())
rest_list = []
for i in range(n):
    each_input = input().split()
    rest_list.append((i, each_input[0], int(each_input[1])))
   
rest_list.sort(key=(lambda x: x[2]), reverse=True)
rest_list.sort(key=(lambda x: x[1]))
print(*[i[0]+1 for i in rest_list], sep='\n')

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

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

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


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


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

for _, _, num in lst:
    print(num)

Solution (Python):

n=int(input())
sp=[[list(input().split()),i] for i in range(n)]
res=sorted(sp, key=lambda x:(x[0][0],-int(x[0][1])))
for t in res:
    print(t[1]+1)

Solution (Python):
N = int(input())
S = sorted((list((lambda y: (y[0], -int(y[1]), x))(input().split()))) for x in range(1, N+1))

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

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

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

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


for _city, _point, idx in SP:
    print(idx)

Solution (Python):

N = int(input())
S = []
P = []


th = {}


ch = {}

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

    
    th[p] = [s, i+1]

    
    if s in ch:
        tmp = ch[s]
        tmp += [p]
        ch[s] = tmp
    else:
        ch[s] = [p]




x = list(set(S))
x.sort()
for city in x:
    tmp = ch[city]
    tmp.sort(reverse=True)
    for i in tmp:
        print(th[i][1])

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

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

for _, _, num in lst:
    print(num)

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()
for j in range(n):
  print(sp[j][2])

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

s.sort(key=lambda p: int(p[1]), reverse=True)
s.sort(key=lambda p: p[0])

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

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.sort()

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

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

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

Solution (Python):

from operator import itemgetter as ig
N = int(input())
S = [0 for i in range(N)]
P = [0 for i in range(N)]
for i in range(N):
    S[i], P[i] = (_ for _ in input().split())
SP = sorted([(i, S[i], int(P[i]))for i in range(N)], key = ig(2), reverse = True)
SP = sorted(SP, key = ig(1))
for i in range(N):
    print(SP[i][0] + 1)

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

l=[[0]*2 for _ in range(n)]

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

l.sort()

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

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

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

city = sorted(city)

for c in city:
    rs = [s for s in rest if s[0]==c]
    rs_sort = sorted(rs, key=lambda x:(x[1]),reverse=True)
    for r in rs_sort:
        print(r[2])

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

SP = {i+1: input().split() for i in range(N)}

for v in SP.values():
    v[1] = int(v[1])


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


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

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

Solution (Python):
from operator import itemgetter

N = int(input())

SP = [input().split() for i in range(N)]

for k, v in enumerate(SP):
    v.insert(0, str(k + 1))
    v[2] = int(v[2])


SP.sort(key=itemgetter(2), reverse=True)


SP.sort(key=itemgetter(1))

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

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


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
data = [{}]*N

for i in range(N):
  tempS, tempP = input().split()
  data[i] = {'ID': i+1, 'Name': tempS, 'Point': int(tempP)}

data_sort = sorted(
  data,
  key = lambda x: (x['Name'], -x['Point'])
)

for i in range(N):
  print(data_sort[i]['ID'])

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

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

Solution (Python):
from operator import itemgetter
N=int(input())
listA=[[] for i in range(N)]
listANS=[]
for i in range(N):
  S,P=input().split()
  listA[i]+=[S,int(P),i+1]
listA.sort()
before=0
if N!=1:
  for i in range(1,N):
    if listA[i-1][0]!=listA[i][0]:
      listN=listA[before:i]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
      before=i
 
    if i==N-1:
      listN=listA[before:N]
      listN.sort(key=itemgetter(1),reverse=True)
      listANS+=listN
else:
  listANS=listA
for i in range(N):
  print(listANS[i][2])

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

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

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

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


point2 = sorted(point, key=itemgetter(1),reverse=True) 

point3 = sorted(point2, key=itemgetter(0)) 


for i in point3:
  print(point.index(i)+1)

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


for j in range(N):
  print(lst[j][2])

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

SP = sorted(SP, key=lambda 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())

dicts = {}
for i in range(N):
    key, value = input().split()
    value = int(value)
    if key not in dicts:
        dicts[key] = [[value, i+1]]
    else:
        dicts[key].append([value, i+1])

dicts = sorted(dicts.items())
for values in dicts:
    for item in sorted(values[1], reverse=True):
        print(item[1])

Solution (Python):
def main():
    N = int(input())
    S = []
    for i in range(N):
        line = [a for a in input().split()]
        line[1] = int(line[1])
        S.append([i+1] + line)
    tmp = sorted(S, key=lambda x:x[2], reverse=True)
    ans = sorted(tmp, key=lambda x:x[1])
    for i in range(len(ans)):
        print(ans[i][0])

main()

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

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

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

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

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

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

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

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

Solution (Python):
Row=int(input())
List=[]

for i in range(Row):
    a,n=input().split()
    List.append((a,int(n)*(-1),i+1)) 
    

List.sort() 

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

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



S = [list(input().split()) for i in range(n)]

for i, s in enumerate(S):
    s.append(i+1)

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

for s, p, n in S:
    print(n)

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


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

L.sort()

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

Solution (Python):
n = int(input())
d = {}
c = 1
for i in range(n):
    i = input().split(" ")
    city = i[0]
    point = int(i[1])
    if city not in d:
        d[city] = [(point,c)]
    else:
        d[city].append([point,c])
    c += 1

sorted_d = sorted(d.items(), key=lambda x:x[0])
for i in sorted_d:
    s_score = sorted(i[1],key=lambda x:x[0],reverse=True)
    for j in s_score:
        print(j[1])

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

Solution (Python):

from operator import itemgetter

n = int(input())

X = []
for i in range(n):
    tmp = input().split(' ')
    X.append((i+1, tmp[0], -int(tmp[1])))
X.sort(key=itemgetter(1, 2))

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

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

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

ans = [x[0] for x in l]
for i in range(len(ans)):
    print(ans[i])

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

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

sl.sort()

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

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

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

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

for i in range(N):
  S, p = map(str, input().split())
  P = 100 - int(p)
  A.append((S, P, i+1))
  
A.sort()
for i in range(N):
  print(A[i][2])

Solution (Python):
def main():
    N = int(input())
    data = []
    for i in range(N):
        s, p = input().split()

        data.append((s, 100 - int(p), i+1))

    for s, p, i in sorted(data):
        print(i)


if __name__ == '__main__':
    main()

Solution (Python):

INPUT_SENTENCES = 1
N = int([input() for i in range(INPUT_SENTENCES)][0])
INPUT_SENTENCES = N
ss = [input() for i in range(INPUT_SENTENCES)]
SP = list(map(lambda x: [x[0], int(x[1])], [[i for i in s.split(" ")] for s in ss]))
spm = {city: map(lambda v: v[1], sorted(list(filter(lambda x: x[0] == city, SP)))) for city in map(lambda v: v[0], SP)}
[[print(SP.index([k,v])+1) for v in sorted(spm[k], reverse=True)] for k in sorted(spm.keys())]

Solution (Python):
N = int(input())
lis = [0]*N
S = [0]*N
P = [0]*N
for k in range(N):
  S[k],P[k] = input().split()
  P[k] = int(P[k])
  lis[k] = [S[k],P[k],k+1]
from operator import itemgetter
lis = sorted(lis, key=itemgetter(1),reverse = True)
lis = sorted(lis, key=itemgetter(0))
for i in range(N):
  print(lis[i][2])

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 range(N):
  print(data[i][2])

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 range(N):
  print(data[i][2])

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

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

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

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

data.sort()

for n in range(N):
    print(data[n][2])

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

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

Solution (Python):
from operator import itemgetter

N = int(input())
SP = [[0,"none",0]]*N
for i in range(N):
	s, p = input().split()
	SP[i] = [i+1, s, int(p)]

SP.sort(key=itemgetter(2), reverse=True)
SP.sort(key=itemgetter(1))
[ print(i[0]) for i in SP ]

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

Solution (Python):



import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

n = int(input())
sp = [list(input().split()) for _ in range(n)]
for i in range(n):
    sp[i].append(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())
r_list = []

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

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

for line in r_list:
    print(line[2])

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

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

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

l = [[0, 0, 0] for j in range(n)]

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

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

l.sort(key=lambda x: x[1])


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

Solution (Python):
N = int(input())
li = []
for i in range(N):
    n,p = input().split()
    li.append([n,int(p),i+1])
li.sort(key =lambda x:x[1], reverse = True)
li.sort(key = lambda x:x[0])
for x in li:
    print(x[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 k in range(n):
  print(l[k][2])

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

for i in range(N):
    s,p = input().split()
    p = int(p)
    cities.append(s)
    try:
        x = cities_index_points[s]
        x.append((i,p))
    except:
        cities_index_points[s] = [(i,p)]

cities = sorted(set(cities))

for c in cities:
    iplist = cities_index_points[c]
    iplist.sort(key=lambda x: x[1], reverse=True)
    for ip in iplist:
        print(ip[0]+1)

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

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

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

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

mylist = []
for i in range(n):
	mylist.append(list(map(str,input().split())))
	mylist[i].append(i+1)

mylist = sorted(mylist,key=lambda mylist:(mylist[0],-int(mylist[1])))
for i in mylist:
	print(i[2])

Solution (Python):
import operator
n=int(input())
rest=[]

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

rest.sort(key=operator.itemgetter(1),reverse=True)
rest.sort(key=operator.itemgetter(0))
for i in range(len(rest)):
    print(rest[i][2])

Solution (Python):
import sys
from collections import deque, defaultdict
import copy
import bisect

sys.setrecursionlimit(10 ** 9)


N = int(input())
res = []
for i in range(N):
    S, P = list(input().split())
    bisect.insort(res, (S, -int(P), i + 1))
for i in range(len(res)):
    print(res[i][2])

Solution (Python):
def Guidebook():
    n = int(input())
    rest = []
    for i in range(n):
        s, p = map(str, input().split())
        rest.append([i+1, s, int(p)])

    rest.sort(key=lambda x:x[2], reverse=True)
    rest.sort(key=lambda x:x[1])
    for i in range(n):
        print(rest[i][0])
if __name__ == "__main__":
    Guidebook()

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

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

Solution (Python):
n=int(input())
l=[]
for i in range(n):
    s=input()
    k=s.split()
    x=int(k[1])

    c=[k[0],x]
    l.append(c)

m=[]
for i in range(n):
    m.append(l[i][0])



m.sort()


boolean=[False for i in range(n)]

for i in range(n):
    tmp=0
    for j in range(n):
        if(m[i]==l[j][0]):
            if(boolean[j]==False):
                if(tmp<l[j][1]):
                    tmp=l[j][1]
    for x in range(n):
        if(l[x][1]==tmp):
            boolean[x]=True
            print(x+1)

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

li = []
for i in range(n):
    li.append(list(map(str, input().split())))
    li[i].append(i+1)

li.sort( key = lambda li : (li[0], -int(li[1])))
for i in li:
    print(i[2])