Problem:
 Score : 200 points    Problem Statement You have decided to write a book introducing good restaurants.
There are N restaurants that you want to introduce: Restaurant 1 , Restaurant 2 , ... , Restaurant N . Restaurant i is in city S_i , and your assessment score of that restaurant on a 100 -point scale is P_i .
No two restaurants have the same score.  You want to introduce the restaurants in the following order:   The restaurants are arranged in lexicographical order of the names of their cities.  If there are multiple restaurants in the same city, they are arranged in descending order of score.   Print the identification numbers of the restaurants in the order they are introduced in the book.      Constraints  1 ≤ N ≤ 100  S is a string of length between 1 and 10 (inclusive) consisting of lowercase English letters.  0 ≤ P_i ≤ 100  P_i is an integer.  P_i ≠ P_j  (1 ≤ i < j ≤ N)         Input Input is given from Standard Input in the following format:  N  S_1  P_1  :  S_N  P_N       Output Print N lines. The i -th line ( 1 ≤ i ≤ N ) should contain the identification number of the restaurant that is introduced i -th in the book.        Sample Input 1 6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40      Sample Output 1 3
4
6
1
5
2  The lexicographical order of the names of the three cities is kazan  <  khabarovsk  <  moscow . For each of these cities, the restaurants in it are introduced in descending order of score. Thus, the restaurants are introduced in the order 3,4,6,1,5,2 .       Sample Input 2 10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100      Sample Output 2 10
9
8
7
6
5
4
3
2
1

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

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

for key in sorted(s):
    for i, score in sorted(s[key], key=lambda t:~t[1]):
        print(i)

Solution (Python):
N=int(input())
li=[]
for i in range(N):
  a,b=input().split()
  b=str(100-int(b)).zfill(3)
  li.append(a+b)
lis = sorted(li)

for i in range(len(li)):
  for j in range(len(li)):
    if lis[i] == li[j]:
      print(j+1)

Solution (Python):
from sys import stdin

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

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

for i in range(n) :print(data.index(ans[i])+1)

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


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


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

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

L.sort(key=lambda x: x[1], )
L.sort(key=lambda x: x[0], reverse=True)
for _, _, i in reversed(L):
    print(i)

Solution (Python):



N = int(input())

sp_list = []

for i in range(N):
    
    sp = input().split(" ")
    sp.append(str(i+1))
    sp_list.append(sp)



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

for i in sp_list:

    print(int(i[2]))

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

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

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

Solution (Python):
P = int(input())
res= []
for i in range(P):
  a, b = input().split()
  res.append((a,int(b)))
res2 = sorted(res, key = lambda x:x[1], reverse = True)
res3 = sorted(res2, key = lambda x:x[0])
for j in range(P):
  print(str(res.index(res3[j])+1))

Solution (Python):
N = int(input())
R = []
for i in range(N):
  s_i, p_i = input().split()
  R.append([s_i, -int(p_i), i+1])
R = sorted(R, key=lambda x: x[1])
R = sorted(R, key=lambda x: x[0])
for r_i in R:
  print(r_i[-1])

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

a = list()

for i in range(N):
        s,p = input().split()
        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 i in a:
        print(i[2])

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

    p = int(p)

    a.append([i+1, s, p])


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

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

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

Solution (Python):
num_restaurants = int(input())
restaurants = [input().split() for _ in range(num_restaurants)]
city_restaurant = dict()
cities = set()
for idx, i in enumerate(restaurants):
    if i[0] in cities:
        city_restaurant[i[0]].append((int(i[1]), idx + 1))
    else:
        city_restaurant[i[0]] = [(int(i[1]), idx + 1)]
        cities.add(i[0])
cities = sorted(list(cities))
for i in cities:
    for j in reversed(sorted(city_restaurant[i], key=lambda x: x[0])):
        print(j[1])

Solution (Python):
n=int(input())
r={i:list(input().split()) for i in range(n)}
r_state=[r[i][0] for i in range(n)]
r_score=[int(r[i][1]) for i in range(n)]
r_state.sort()
r_score.sort(reverse=True)
l=[]

for i in range(n):
  for j in range(n):
    for k in range(n):
      if k in r.keys():
        if r[k]==[r_state[i],str(r_score[j])]:
          l.append(k+1)
          r.pop(k)
for item in l:
  print(item)

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

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

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

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

Solution (Python):
N = int(input())
assign = []
for index in range(1,N+1):
    S, P = map(str, input().split())
    P = int(P)
    assign.append([S, P, index])

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

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

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

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


if __name__ == '__main__':
    n = int(input())
    ary = []
    city = []
    ans = []
    for i in range(n):
        x, y = input().split()
        city.append(x)
        ary.append([x, int(y), i+1])
    
    cities = sorted(set(city), key=city.index)
    cities.sort()
    for c in cities:
        tmp = [x for x in ary if x[0] == c]
        tmp.sort(reverse=True)
        for t in tmp:
            ans.append(t)

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

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

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

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

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

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

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

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

for k in range(N):
    print(E[k][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())

data = dict()

for i in range(1, n + 1):
    city, score = input().split()
    if city not in data:
        data[city] = []
    data[city].append([int(score), i])

for key in sorted(data.keys()):
    for _, num in sorted(data[key], key=lambda x: -x[0]):
        print(num)

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

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

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

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

Solution (Python):
n = input()
li = [input() for i in range(int(n))]

disp = {}

for i in range(int(n)):
    city, point = li[i].split()
    if not (city in disp.keys()):
        disp[city] = {}
    disp[city][point] = i + 1

for elm in sorted(disp.keys()):
    for item in sorted(map(int, disp[elm].keys()), reverse=True):
        print(disp[elm][str(item)])

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

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

for i in range(N):
    city, point = input().split()
    point = int(point)
    s = (city, point, i+1)
    S.append(s)

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

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

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

Solution (Python):
n = int(input())
d = {}

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

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

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

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

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

for i in sorted(sorted(l, key=lambda x: int(x[1]), reverse=True), key=lambda x: x[0]):
    print(l.index(i) + 1)

Solution (Python):
from sys import stdin, stdout
_write = stdout.write
_readline = stdin.readline

n = int(_readline())
d = dict()

for i, line in enumerate(stdin, 1):
  s, p = line.strip().split()
  k = s.ljust(10, ' ') + str(100 - int(p)).zfill(3)
  d[k] = i

for k in sorted(d.keys())[:n]:
  _write(str(d[k]) + '\n')

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

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

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

restaurant_data = [[i+1]+(list(input().split())) for i in range(N)]
restaurant_data = list(map(lambda x:[x[0],x[1],int(x[2])],restaurant_data))
restaurant_data = sorted(restaurant_data, key=lambda x: -1*x[2])
restaurant_data = sorted(restaurant_data,key=lambda x:x[1])

for ans in list(map(lambda x:x[0],restaurant_data)):
  print(ans)

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

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

for j in range(len(t)):
  print(t[j][0])

Solution (Python):
N = int(input())
R = []
for i in range(N):
  s_i, p_i = input().split()
  R.append([s_i, -int(p_i), i+1])
R = sorted(R, key=lambda x: x[1])
R = sorted(R, key=lambda x: x[0])
for r_i in R:
  print(r_i[-1])

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

Solution (Python):
N = int(input())
lst = []
klst = []
for i in range(N):
    k, v = input().split()
    lst.append((i+1, k, int(v)))
    klst.append(k)
klst = list(set(klst))
klst.sort()



ans = [[] for i in range(len(klst))]


counter = 0
for name in klst:
    
    for res in lst:
        a, b, c = res
        if b == name:
            ans[counter].append((c, a))
    ans[counter].sort()
    
    counter += 1


for answer in ans:
    for (a, b) in reversed(answer):
        print(b)

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


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


for i in range(N):
    SP[i][1] = int(SP[i][1])
SP.sort(reverse=True)
SP.sort(key=lambda x: x[0])


for a, b, c in SP:      
	print(c + 1)

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

for i in range(N):
  mylist.append(input().split()+[i])

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

mylist=sorted(sorted( mylist ,key=lambda x:x[1],reverse=1),key=lambda x:x[0])
    
for s,t,r in mylist:
    print(r+1)

Solution (Python):

s = []
N = int(input())

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



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

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

Solution (Python):
import sys
input = sys.stdin.readline
ri = lambda: int(input())
rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]

rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

N=ri()
SP = []
for i in range(1,N+1):
    s,p = rl()
    SP.append([s,p,i])

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

Solution (Python):
N = int(raw_input())
SP = [raw_input().split() + [i + 1] for i in range(N)]
for i in range(N):
    SP[i][1] = -int(SP[i][1])
SP.sort()
for i in range(N):
    print SP[i][2]

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

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

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

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

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

Solution (Python):
[print(x[2])for x in sorted([(s[0],-int(s[1]),i+1)for i,s in enumerate([input().split()for _ in range(int(input()))])])]

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

sp = [input().split() for _ in range(n)]
sp = [(_sp[0], -int(_sp[1]), i+1) for i, _sp in enumerate(sp)]

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

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

Solution (Python):


N = int(input())
guidebook = dict()

for i in range(N):
    d = input().split()
    ci = d[0]
    pi = int(d[1])
    restaurants = guidebook.get(ci, dict())
    restaurants[pi] = i+1
    guidebook[ci] = restaurants


city_names = sorted(guidebook.keys())
for cn in city_names:
    restaturants = guidebook[cn]
    
    r_keys = list(restaturants.keys())
    r_keys.sort(reverse=True)
    for r_key in r_keys:
        print(restaturants[r_key])

Solution (Python):
a = int(input())
l = []
for i in range(a):
    ta,tb = map(str,input().split())
    l.append([ta,-int(tb),i+1])
l.sort()
for i, j , k in l:
    print(k)

Solution (Python):

a = int(input())
l = []
for i in range(a):
    ta,tb = map(str,input().split())
    l.append([ta,-int(tb),i+1])
l.sort()
for i, j , k in l:
    print(k)

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

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

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

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

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

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

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

Solution (Python):
N=int(input())
restranlist=[]
for i in range(N):
    l=input().split()
    restranlist.append([str(l[0]),-int(l[1]),i])
    
    restranlist_s=sorted(restranlist)
    
for i in range(N):
    print(restranlist_s[i][2]+1)

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

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

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

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

Solution (Python):
from operator import itemgetter as get
Res=[]
for i in range(int(input())):
    a,b=input().split()
    Res.append((a,int(b),i))
Res.sort(key=get(1))
Res.reverse()
Res.sort(key=get(0))
for i in Res:
    print(i[2]+1)

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

P.sort()

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

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

list2=[]

for i in range(n):
    list=[j for j in input().split()]
    list[1]=int(list[1])
    list2.append(list)



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



for i in list3:
    print(list2.index(i)+1)

Solution (Python):
N=int(input())
L=[]
n=1
while n<=N:
    L.append(list(input().split()))
    L[n-1][1]=int(L[n-1][1])*(-1)
    L[n-1].append(n)
    n+=1
L_sorted=sorted(L, key=lambda _:(_[0],_[1]))
n=1
while n<=N:
    L_sorted[n-1].append(n)
    n+=1
n=1
while n<=N:
    print(L_sorted[n-1][2])
    n+=1

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



for i in range(N):
  deleteIndex=0
  outputIndex=Index[0]
  minS=S[0]
  maxP=P[0]
  for j in range(1,N-i):
    if (S[j] < minS) or ((S[j] == minS) and (P[j] > maxP)):
      deleteIndex=j
      outputIndex=Index[j]
      minS=S[j]
      maxP=P[j]
  print(outputIndex)
  del Index[deleteIndex]
  del S[deleteIndex]
  del P[deleteIndex]

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

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

Solution (Python):
n = int(input())
def inserter(sp, splist) :
    if  splist == [] :
        return [sp]
    elif sp[0] < splist[0][0] :
        return [sp] + splist
    elif sp[0] == splist[0][0] :
        if int(sp[1]) > int(splist[0][1]) :
            return [sp] + splist
        else :
            return [splist[0]] + inserter(sp, splist[1:])
    else :
        return [splist[0]] + inserter(sp, splist[1:])
lst = []
for i in range(n) :
    s, p = input().split()
    lst = inserter([s, p, i+1], lst)
for j in lst :
    print(j[2])

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

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

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

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

for i in range(n):
    s, p = input().split()
    p = 100 - int(p)
    restaurant = "{} {:03} {}".format(s, p, i+1)
    restaurants.append(restaurant)
sorted_restaurants = sorted(restaurants)

for i in range(n):
    id = sorted_restaurants[i].split()[-1]
    print(id)

Solution (Python):
N = int(input())
SP = []
for n in range(N):
    l = input().split()
    l.append(n+1)
    SP.append(l)

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

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

Solution (Python):

def guide():
    n = int(raw_input())
    d = {}
    j = []
    for _ in range(n):
        a, b = raw_input().split(' ')
        j.append(int(b))
        d[int(b)] = a

    c = {}
    f = []
    for a in d:
        e = d[a]
        f.append(e)
        if c.has_key(e):
            c[e].append(a)
        else:
            c[e] = []
            c[e].append(a)

    f = list(set(f))
    f.sort()
    h = []
    for g in f:
        c[g].sort(reverse=True)
        h += c[g]

    for k in h:
        print(j.index(k)+1)

guide()

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

elems.sort()
for elem in elems:
    print(elem[2])

Solution (Python):

w = int(input())
list1 = []

for i in range(w):
  s,p = input().split()
  p = 100 - int(p)
  list1.append("%s %03d %03d" % (s,p,i+1))

sorted_list = sorted(list1)
for i in range(w):
  id = int(sorted_list[i][-3:])
  print(id)

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

for i in range(n):
    s, p = input().split()
    p = 100 - int(p)
    restaurants.append("%s %03d %03d" % (s, p, i + 1))
sorted_restaurants = sorted(restaurants)

for i in range(n):
    id = int(sorted_restaurants[i][-3:])
    print(id)

Solution (Python):
a = int(input())
l = [list(input().split()) for i in range(a)]
b = sorted(l, key=lambda x:(x[0], -int(x[1])))
for i in b:
  for k, j in enumerate(l, 1):
    if j == i:
      print(k)

Solution (Python):
from operator import itemgetter
N = int(input())
guide = []
for i in range(N):
  lst = input().split(' ')
  guide.append([i+1,lst[0],int(lst[1])])
guide = sorted(guide, key=itemgetter(2),reverse=True)
guide = sorted(guide, key=itemgetter(1))
for i in range(N):
  print(guide[i][0])

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

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

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

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

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

Solution (Python):
import sys

def main():
    num = int(sys.stdin.readline())
    
    input = [None] * num

    for i in range(num):
        read = sys.stdin.readline().split()
        input[i] = [i+1, read[0], int(read[1])]

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

    for restaurant in input:
        print(restaurant[0])

if __name__ == "__main__":
    main()

Solution (Python):
def make_guide():
    num = int(input())
    lst = [(i + 1, input().split()) for i in range(num)]
    
    
    
    lst = sorted(lst, key=lambda t: int(t[1][1]), reverse=True)
    lst = sorted(lst, key=lambda t: t[1][0])
    return lst


def test_display():
    lst = make_guide()
    for i, guides in lst:
        print(str(i) + " " + guides[0] + " " + guides[1])


def display():
    lst = make_guide()
    for i, guides in lst:
        print(i)


if __name__ == "__main__":
    display()

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

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

s = sorted(S)

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

Solution (Python):
N = int(input())
SP = [(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 s,p,j in SP:
    print(j)

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

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

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

Solution (Python):
def main():
    N = int(input())
    lst = []
    for i in range(1, N+1):
        inp = input().split()
        inp[1] = int(inp[1]) * -1
        inp.append(i)
        lst.append(inp)
    newLst = sorted(lst)
    for j in range(N):
        print(newLst[j][2])
if __name__ == '__main__':
    main()

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

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

arr= [0]*n

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

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

for ele in arr:
	print(ele[2])

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

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

Solution (Python):
import copy
n=input()
mylist=[]
for i in range(n):
   mylist.append(raw_input().split())
mylistn=[]
for i in range(n):
    mylistn.append([i+1, mylist[i][0],int(mylist[i][1])])
mylistnn=sorted(mylistn,key=lambda x:(x[1],-x[2]))
for i in range(n):
    print(mylistnn[i][0])

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

sp.sort(key=itemgetter(1), reverse=True)
sp.sort(key=itemgetter(0))

for s,p,i in sp:
    print(i, end=" ")

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

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

for ResNum in range(0, N + 1):
    if ResNum <= N - 1:
        Restaurants[ResNum][1] = int(Restaurants[ResNum][1])

    if ResNum > 0:
        Restaurants[ResNum - 1].append(ResNum)

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



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

Solution (Python):




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

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
a = []
b = []
for _ in range(N):
    s = input().split()
    a.append(s[0])
    b.append(int(s[1]))
ind = list(range(1, N+1))
so = list(zip(a, b, ind))
so.sort(key=lambda x: x[1], reverse=True)
so.sort(key=lambda x: x[0], )
for s in so:
    print(s[2])

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

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

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

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

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

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

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

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

Solution (Python):
n=int(input())
l=[list(input().split()) for i in range(n)]
for i in range(n):
  l[i][1]=-int(l[i][1])
L=sorted(l)
for i in range(n):
  print(l.index(L[i])+1)

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

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

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

Solution (Python):


N = int(input())
SP = []
for i in range(N):
    SP.append({"id" :i, "data": input().split()})

tmp = sorted(SP, key=lambda x:int(x["data"][1]), reverse=True)

for k in sorted(tmp, key=lambda x:x["data"][0]):
    print(k["id"]+1)

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

inputs.sort(key=lambda x: x[2], reverse=True)
inputs.sort(key=lambda x: x[1])
for x in inputs:
  print(x[0] + 1)

Solution (Python):
N = int(input())
SP = []
for i in range(N):
    s,p = input().split()
    SP.append([s,int(p),i+1])
SP.sort(key=lambda x:-x[1])
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 = True), key = lambda x:x[0])
for s, t, r in p:
    print(r + 1)

Solution (Python):
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])
SP.sort(key=lambda x:x[0])
for i in range(N):
    print(SP[i][2]+1)

Solution (Python):
from operator import itemgetter
N = int(input())
L = []
for i in range(N):
    a,b = input().split()
    L.append([i,a,int(b)])
L = sorted(L, key=itemgetter(2), reverse=True)
L = sorted(L, key=itemgetter(1))
for j in range(N):
    print(L[j][0]+1)

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

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

Solution (Python):
for*_,i in sorted((t.split()[0],-int(t.split()[-1]),i)for i,t in enumerate(open(0)))[1:]:print(i)

Solution (Python):

from operator import itemgetter

N = int(input())

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

sorted_SP = sorted(SP, key=itemgetter(2), reverse=True)
sorted_SP = sorted(sorted_SP, key=itemgetter(1))

for n in range(N):
    print(sorted_SP[n][0])

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

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

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

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

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

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

Solution (Python):
n=int(input())
A=[[0 for col in range(3)]for row in range(n)]

for i in range(n):
  s,p=input().split()
  A[i][0],A[i][1],A[i][2]=s,p,i+1

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

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

Solution (Python):
import pprint

N = int(input())
lst = []
for _ in range(N):
  hoge = list(input().split())
  hoge2 = _
  hoge3 = [hoge,hoge2]
  lst.append(hoge3)

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

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

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

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

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

Solution (Python):
db = {}
n = int(input())
for i in range(n):
  si, pi = input().split()
  if not si in db:
    db[si] = []
  db[si].append({"order": i, "score": int(pi)})

sorted_keys = sorted(db.keys(), key=lambda x: x)
for key in sorted_keys:
  
  sorted_by_score = sorted(db[key], key=lambda x: x["score"], reverse=True)
  for ans in sorted_by_score:
    print("{}".format(ans["order"] + 1))