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())
L=[]
for i in range(N):
    a,b=input().split()
    L.append((a,int(b),i+1))
L.sort(key=lambda x:x[1],reverse=True)
L.sort(key=lambda x:x[0])
for i in range(N):
    print(L[i][2])

Solution (Python):
N = int(input())
S = []
for i in range(N):
  S_tmp, P_tmp = input().split()
  P_reverse = chr(100 - int(P_tmp))
  S.append(S_tmp + str(P_reverse) + '_' + str(i+1))
for i in range(N):
  S_sort = sorted(S)
  print(S_sort[i].split('_')[-1])

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

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

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

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

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

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

Solution (Python):
n = int(input())
s = {i+1: tuple(input().split()) for i in range(n)}
for k, v in sorted(s.items(), key=lambda x: (x[1][0], -int(x[1][1]))):
    print(k)

Solution (Python):
dic={}
N = int(input())
for i in range(N):
  inp = input().split()
  S = inp[0]
  P = int(inp[1])
  if S in dic:
    dic[S].append([P,i])
  else:
    dic[S] = [[P,i]]

for key in sorted(dic):
    for j in sorted(dic[key], reverse=True):
        print(j[1]+1)

Solution (Python):


n = input()

l = []

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

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

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

Solution (Python):
from operator import itemgetter

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

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

Solution (Python):
n =int(input())
book = []
for i in range(1,n+1):
      s,p = input().split()
      p = int(p)
      book.append((i,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())
sp=[]
for _ in range(N):
    sp.append([i for i in input().split()])

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

sp2=sorted(sp)

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

Solution (Python):
from collections import defaultdict
import heapq
import sys
input = sys.stdin.readline
 
 
def main():
    N = int(input())

    D = []
    d = defaultdict(list)
    for i in range(1, N+1):
        s, p = input().split()
        D.append([s, int(p)*(-1), i])
    D.sort()

    for d in D:
        print(d[2])
        
 
 
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
li = []
for i in range(n):
  li_1 = input().split()
  li_1[1] = int(li_1[1])
  li_1.append(i+1)
  li.append(li_1)
li = sorted(li, key=lambda x: x[0])
new_li = []
new_li_2 = []
a = li[0][0]
for i in range(n):
  if a == li[i][0]:
    new_li_2.append(li[i])
    if i == n-1:
      new_li.append(new_li_2)
  else:
    new_li.append(new_li_2)
    new_li_2 = []
    a = li[i][0]
    new_li_2.append(li[i])
    if i == n-1:
      new_li.append(new_li_2)

for i in range(len(new_li)):
  new_li[i] = sorted(new_li[i], key=lambda x: x[1])
  new_li[i].reverse()
ans_li =[]
for i in range(len(new_li)):
  for j in range(len(new_li[i])):
    ans_li += [new_li[i][j]]
for i in range(n):
  print(ans_li[i][2])

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

Solution (Python):
N = int(input())
names = set()
citydict = dict()
for i in range(N):
    S,P = input().split()
    names.add(S)
    if S in citydict:
        citydict[S].append((int(P),i))
    else:
        citydict[S] = [(int(P),i)]

for name in sorted(names):
    for point in sorted(citydict[name],reverse = True):
        print(point[1] + 1)

Solution (Python):
n = int(input())
citynames = set()
citydict = dict()

for i in range(n):
  s,p = input().split()
  citynames.add(s)
  if not s in citydict:
    citydict[s] = [(int(p), i)]
  else:
    citydict[s].append((int(p), i))

for name in sorted(citynames):
  for point in sorted(citydict[name], reverse=True):
    print(point[1]+1)

Solution (Python):
import collections

n = int(input())

scores = collections.defaultdict(list)

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



for city in sorted(scores):
    sorted_score = sorted(scores[city], key=lambda x: x[1], reverse=True)
    for v in sorted_score:
        print(v[0])

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

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

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

for elem in sorted_rest:
    print(elem[2])

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


tmp = sorted(restaurants, key=lambda x: x[1], reverse=True)
sorted_rest = sorted(tmp, key=lambda x: x[0])

for elem in sorted_rest:
    print(elem[2])

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

list_res = []
for i in range(n):
    a, b = map(str, input().split())
    list_res.append([a,int(b) * -1, i + 1])

list_res = sorted(list_res, key = itemgetter(0, 1))


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

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

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

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

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

for i in range(N):
    city, score = input().split()
    r.append((city, int(score), i+1))

r = sorted(r, key = lambda x:(x[0], -x[1]))
for city, score, num in r:
    print(num)

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

Solution (Python):
n = int(input())
score = []
for i in range(n):
    a, b = list(input().split())
    tmp = [a, int(b)]
    tmp.append(i)
    score.append(tmp)

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


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

Solution (Python):

N = int(input())
S = [""] * N
P = [0] * N

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


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

num_list = [i+1 for i in range(N)]
my_list = [(i, j, k) for i, j, k in  zip(S, P, num_list)]
my_list = sorted(my_list, key = lambda x:(x[0], -x[1]))

for k in range(N):
    print(my_list[k][2])

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

for i in range(n):
  s,p=input().split()
  d[s+"{0:03d}".format(100-int(p))]=i+1

d2=sorted(d.items())
for i in range(len(d2)):
  print(d2[i][1])

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

Solution (Python):
n = int(input())
s = []
p = []
ans = [0]*n
for i in range(n):
    s1,p1 = [str(i) for i in input().split()]
    s.append(s1)
    p.append(p1)
    ans[i] = i + 1
for i in range(n):
    p[i] = int(p[i])
flag = 1
while flag:
    flag = 0
    for i in range(n-1,0,-1):
        if s[i] < s[i-1]:
            s[i],s[i-1] = s[i-1],s[i]
            p[i],p[i-1] = p[i-1],p[i]
            ans[i],ans[i-1] = ans[i-1],ans[i]
            flag = 1
flag = 1
while flag:
    flag = 0
    for i in range(n-1):
        if s[i] == s[i+1] and p[i] < p[i+1]:
            p[i],p[i+1] = p[i+1],p[i]
            ans[i],ans[i+1] = ans[i+1],ans[i]
            flag = 1
for i in range(n):
    print(ans[i])

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

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

Solution (Python):
n = int(input())
number = [0] * n
s = [0] * n
p = [0] * n

for i in range(n):
  number[i] = i+1
  s[i], p[i] = input().split()
  p[i] = int(p[i])
  
for i in range(n):
  for j in range(1, n-i):
    if s[j-1] > s[j]:
      s[j-1], s[j] = s[j], s[j-1]
      p[j-1], p[j] = p[j], p[j-1]
      number[j-1], number[j] = number[j], number[j-1]
    elif (s[j-1] == s[j]) and (p[j-1] < p[j]):
      s[j-1], s[j] = s[j], s[j-1]
      p[j-1], p[j] = p[j], p[j-1]
      number[j-1], number[j] = number[j], number[j-1]
      
for i in range(n):
  print(number[i])

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

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

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

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

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

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

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

Solution (Python):

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
from collections import defaultdict
from operator import itemgetter
N = int(input())

A = [[] for _ in range(N)]
for i in range(N):
    S, P = [x.strip() for x in input().split()]
    A[i].append(S)
    A[i].append(int(P))

B = sorted(A, key=itemgetter(1), reverse=True)
B = sorted(B, key=itemgetter(0))

for i in B:
    for j, v in enumerate(A):
        if i[0] == v[0] and i[1] == v[1]:
            print(j + 1)
            break

Solution (Python):
N = int(input())
SP = [list(map(str,input().split())) for _ in range(N)]
for i in range(N):
    SP[i][1] = int(SP[i][1])
for i in range(N):
    SP[i].append(i+1)
SP.sort()
for i in range(N**2):
    for i in range(N-1):
        if SP[i][0] == SP[i + 1][0] and SP[i][1] < SP[i+1][1]:
            A = SP[i]
            SP[i] = SP[i + 1]
            SP[i + 1] = A
for i in range(N):
    print(SP[i][2])

Solution (Python):
N = int(input())
points = []
for i in range(N):
    points.append(input().split())
for j, point in enumerate(points):
    point.append(j+1)
points.sort(key=lambda x: int(x[1]), reverse=True)
points.sort(key=lambda x: x[0])
for p in points:
    print(p[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.sort(key= lambda x:x[1] ,reverse=True)
sp.sort(key= lambda x:x[0] )

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

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

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

Solution (Python):

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

Solution (Python):
n = int(input())
d = [list(map(str, input().split())) for i in range(n)]
for i in range(1, n+1):
    d[i-1].append(i)
    d[i-1][1] = int(d[i-1][1])
d.sort()
ans = []
tmp = []
now_city = d[0][0]
for i in range(n):
    if now_city == d[i][0]:
        tmp.append(d[i])
    else:
        tmp.sort(key=lambda x: x[1], reverse=True)
        for j in range(len(tmp)):
            ans.append(tmp[j][2])
        tmp = []
        tmp.append(d[i])
        now_city = d[i][0]
tmp.sort(key=lambda x: x[1], reverse=True)
for j in range(len(tmp)):
    ans.append(tmp[j][2])
for i in ans:
    print(i)

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

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

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

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

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

S.sort()

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

Solution (Python):
from operator import itemgetter

N = int(input())
l = []
x = 0
y = 1
for i in range(N):
  a = input().split()
  a[1] = int(a[1])
  l.append(a)
  l[x].insert(2,y)
  x +=1
  y +=1



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


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

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

res = [] 
for i in range(n):
    si, pi = input().split()

    res.append([i, si, int(pi)])

for i in sorted(res, key = lambda w: (w[1], -w[2])):
    print(i[0]+1)

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

for num in lis:
  print(num[0])

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

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

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

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

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


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

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

Solution (Python):
n=int(input())
a=[]
for i in range(n):
    x,y=input().split()
    a.append((i+1,x,int(y)))
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):
N = int(input())
S = []
for n in range(N):
    S.append(input())
d={}
for s in S:
    s=s.split(" ")
    c=s[0]
    n=int(s[1])
    if c not in d:
        d[c]=[]
    d[c].append(n)

d_sorted=sorted(d.items(), key=lambda x:x[0])
for k in d_sorted:
    k[1].sort(reverse=True)
    for p in k[1]:
        key = k[0] + " " + str(p)
        print(S.index(key)+1)

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

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

for k,vs in sorted(d.items(), key=itemgetter(0)):
    for i,p in sorted(vs, key=itemgetter(1), reverse=True):
        print(i)

Solution (Python):
n = int(input())
spList = [input().split() for _ in range(n)]
for i in range(n):
    spList[i][1] = 100 - int(spList[i][1])

spResultList = sorted(spList)
for i in range(n):
    print(spList.index(spResultList[i]) + 1)

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

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

Solution (Python):
n = int(input())
stack = [['zzzzzzzzzzz', -1]]
for i in range(n):
    s, p = input().split()
    p = int(p)
    stack.append([s, p])
cnt = {0}
for i in range(len(stack)-1):
    x = 0
    for j in range(1,len(stack)):
        if j in cnt:
            continue
        else:
            if stack[x][0] > stack[j][0]:
                x = j
            elif stack[x][0] == stack[j][0] and stack[x][1] < stack[j][1]:
                x = j
    cnt.add(x)
    print(x)

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

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

info=[]

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

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

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

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

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

for x in X_sorted:
    print(x[1])

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

Solution (Python):


N=int(input())
l=[["a",-1] for i in range(N)]

for i in range(N):
    a,b=map(str,input().split())
    b=int(b)
    l[i]=[a,200-b,i+1]

l.sort()

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

city_pts = {}
cities = set()

for i in range(n):
    city, pts_raw = input().split()
    pts = int(pts_raw)

    if city in cities:
        city_pts[city].append((pts,i))
    else:
        city_pts[city] = [(pts,i)]

    cities.add(city)

for c in sorted(cities):
    pts = city_pts[c]

    for p in sorted(pts,reverse=True):
        print(p[1]+1)

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

_r=sorted(r, key=lambda x: (x[1][0], x[1][1]), reverse=True)
for __r in sorted(_r, key=lambda x: x[1][0]):
    print(__r[0])

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

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

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

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

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

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


if __name__ == "__main__":
    main()

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

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

list2=sorted(list,key =lambda x:(x[1], -int(x[2])))

for a,b,c in list2:
    print(a)

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

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

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

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

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

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

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

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

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

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

Solution (Python):
n = int(input())
a = []
for i in range(n):
    s,p = map(str, 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())
sp=[[i for i in input().split()] for j in range(n)]
i=1
isp=[[]for i in range(n)]
for s,p in sp:
    isp[i-1]=[s,-int(p),i]
    i+=1
isp=sorted(isp)
for s,p,i in isp:
    print(i)

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    x = []
    for i in range(n):
        a, b = list(map(str, str(input().rstrip('\n')).split()))
        x.append([a, -int(b), i+1])
    x.sort()
    for i in range(n):
        print(x[i][2])


if __name__ == '__main__':
    slove()

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

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

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

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

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

for i in range(N):
  res,score = input().split()
  score = int(score)
  li.append([res,-score,i+1])
  
li.sort()

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

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

Solution (Python):
N = int(input())
A = [0]*N
P = [0]*N
for i in range(N):
  D = list(map(str, input().split()))
  A[i] = D[0]
  P[i] = int(D[1])

for i in range(N):
  A.insert(2*i+1, P[i])

for i in range(N):
  A.insert(3*i+2, i+1)


B = [A[i:i + 3] for i in range(0, len(A), 3)]

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

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

Solution (Python):
from operator import itemgetter

n = int(input())
guide = []
for i in range(1, n + 1):
    s, p = input().split()
    guide.append((s, int(p), i,))
guide.sort(key=itemgetter(1), reverse=True)
guide.sort(key=itemgetter(0))
[print(g[2]) for g in guide]

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

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

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

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

Solution (Python):
n = int(input())
ds = {}
for i in range(1, n+1):
    s, p = input().split()
    dp = ds.get(s,{})
    dp[int(p)] = i
    ds[s] = dp
for si in sorted(ds.keys()):
    s = ds[si]
    for pi in sorted(s.keys(), reverse=True):
        print(s[pi])

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

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

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

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

for i in ll2:
    print(ll.index(i)+1)

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

Solution (Python):
N = int(input())
a = [list(map(str, input().split())) for _ in range(N)]
tmp = sorted(a, key = lambda x:(int(x[1])), reverse = True)
array = sorted(tmp, key = lambda x:(x[0]))

for i in range(N):
    print(a.index(array[i]) + 1)

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

Solution (Python):
from operator import itemgetter
n = int(input())
sp = []
for i in range(n):
    s_input, p_input = input().split()
    sp.append([s_input] + [int(p_input)] + [i])
sorted1 = sorted(sp, key=itemgetter(1), reverse=True)
sorted2 = sorted(sorted1, key=itemgetter(0))

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

Solution (Python):
from collections import Counter,defaultdict
import sys,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

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

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

Solution (Python):
import numpy as np

N = int(input())
R = []
for i in range(N):
    s, p = input().split()
    R.append([i+1, s, -int(p)])
    
R_sort = sorted(R, key=lambda x : (x[1], x[2]))

for city in R_sort:
    print(city[0])

Solution (Python):
while True:
    try:
        N = int(input())
        SP = []
        for i in range(1, N+1):
            S, P = map(str, input().split())
            SP.append([S, int(P), i])
            
        for sp in sorted(SP, key=lambda x: (x[0], -x[1])):
            print(sp[2])
    except:
        break

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

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

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

Solution (Python):
N, *A = open(0).read().split()
A = [(s, -int(p)) for s, p in zip(*[iter(A)] * 2)]
I = [i for i in range(int(N))]
I.sort(key=lambda i: A[i])
for i in I:
    print(i + 1)

Solution (Python):
N = int(input())
S =[""]*N
R =[0]*N
for i in range(N):
    S[i], R[i] = input().split()
Ri = [0]*N
for i in range(N):
    Ri[i] = -1*int(R[i])
SR = [0]*N
for i in range(N):
    SR[i]=[S[i],Ri[i],i+1]
SR.sort()
for i in range(N):
    print(SR[i][2])

Solution (Python):
N = int(input())
S, P = [""], [0]
for _ in range(N):
    s, p = input().split()
    S.append(s)
    P.append(int(p))

I = [i for i in range(1, N + 1)]
I.sort(key=lambda i: P[i], reverse=True)
I.sort(key=lambda i: S[i])

print(*I, sep='\n')

Solution (Python):
n = int(input())
r = []
for i in range(1, n+1):
  hoge = input().split()
  hoge.append(i)
  r.append(hoge) 
tmp = sorted(r, key=lambda x:int(x[1]), reverse=True)
res = sorted(tmp, key=lambda x:x[0])
for arr in res:
  print(arr[2])

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

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