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())
a = []
for i in range(1, n+1):
    b,c = input().split()
    a.append([i,b,int(c)*-1])
a = sorted(a, key=lambda x: (x[1], x[2]))
for i in range(n):
    print(a[i][0])

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

cities.reverse()

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

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

Solution (Python):
import numpy as np
N = int(input())
S = list()
P = list()
SP = list()
for n in range(N):
    s, p = input().split()
    SP.append([s, -int(p), n+1])
SP.sort()
for s,p,i in SP:
    print(i)

Solution (Python):

import sys










def main():
    n = int(sys.stdin.readline().rstrip())
    
    order = []
    cities = []
    for i in range(1, n+1):
        city, score = sys.stdin.readline().split()
        order.append([city, int(score), i])
        cities.append(city)

    res = dict((c, list()) for c in set(cities))
    for i in range(n):
        res[order[i][0]].append(order[i][1:])

    for city, score in sorted(res.items()):
        for s in sorted(score, reverse=True):
            print(s[1])

if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input().strip())
r = [[0] * 2] * n

for i in range(n):
    r[i] = list(map(lambda x: x.strip(), input().split()))

for i in range(n):
    r[i].extend([i + 1])

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

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

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

Solution (Python):
import sys
import numpy as np
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    SP=['']*N
    for i in range(N):
        S,P=input().split()
        SP[i]=S+str((100-int(P))).zfill(3)
    SP_argsort=np.argsort(SP)
    for i in SP_argsort:
        print(i+1)

if __name__ == '__main__':
    main()

Solution (Python):
a=int(input())
c=[input().split(" ")for i in range(0,a)]
for i in c:
    i[1]=int(i[1])

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

for j in d:
    print(c.index(j)+1)

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

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



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

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

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

for s,p,n in sorted(spl):
    print(n+1)

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

Solution (Python):
from operator import itemgetter
n=int(input())
li=[]
for i in range(n):
  temp=input().split()
  li.append({"city":temp[0],"point":-int(temp[1]),"ind":i+1})
ans=sorted(li,key=itemgetter("city","point"))

for dic in ans:
  print(dic["ind"])

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

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

for i in range(N):
  l[i][1] = int(l[i][1])
  l[i].append(i+1)
  l[i][1] = 100-l[i][1]
  
l.sort()

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

Solution (Python):
import numpy as np
rest = {}
N = int(input())
for i in range(N):
    s,p = input().split()
    if(s not in rest.keys()):
        rest[s] = [[int(p)],[i+1]]
    else:
        rest[s][0].append(int(p))
        rest[s][1].append(i+1)

sort_rest = sorted(rest.keys())
for r in sort_rest:
    argsort_ = np.argsort(np.array(rest[r][0]))[::-1]
    for i in argsort_:
        
        
        print(rest[r][1][i])

Solution (Python):
N = int(input())
dic ={}

for i in range(N):
    line = input().split()
    dic[i] = [line[0], int(line[1])]


ans = []
for index, i in enumerate(sorted(dic.items(), key= lambda x: (x[1][0],-x[1][1]))):
    ans.append([i])

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

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

place = {}
for i in range(n):
  tmp = input().split()
  s = tmp[0]
  k = int(tmp[1])
  pt = (k, i)
  if s in place:
    place[s].append(pt)
  else:
    place[s] = [pt]

placek = sorted(place)

for i in placek:
  pts = sorted(place[i], reverse=True)
  for pt in pts:
    print(pt[1] + 1)

Solution (Python):
N = int(input())
SP = {}
for i in range(N):
    line = input().split()
    SP[i] = [line[0], int(line[1])]
    
ans = []
for i, index in enumerate(sorted(SP.items(), key= lambda x: (x[1][0], -x[1][1]))):
    ans.append([index, i])

for ls in ans:
    print(ls[0][0] + 1)

Solution (Python):



from operator import itemgetter, attrgetter

N = int(input())


score_chart = []
for i in range(N):
    array = list(input().strip().split())
    array.append(i+1)
    score_chart.append(array)
for i in range(N):
    score_chart[i][1] = int(score_chart[i][1])
s = sorted(score_chart, key=itemgetter(1),reverse=True)
s = sorted(s, key=itemgetter(0))


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

Solution (Python):

import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    SP=[[i]+list(input().split()) for i in range(N)]
    SP.sort(key=lambda x: int(x[2]), reverse=True)
    SP.sort(key=lambda x: x[1])
    for v in SP:
        print(v[0]+1)


if __name__ == '__main__':
    main()

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

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

dic = []
S, P = [], []
for i in range(N):
    _s, _ = [x for x in input().split()]
    _p = int(_)
    S.append(_s)
    P.append(_p)
    dic.append((_s, -_p, i+1))

dic.sort()

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

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

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

for i in range(N):
    name, point = input().split()
    data.append((name, int(point), i))

data.sort(key=lambda x:-x[1])
data.sort(key=lambda x:x[0])
for d in data:
    print(d[2] + 1)

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

for i in range(N):
    name, point = input().split()
    data.append((name, int(point), i))

data.sort(key=lambda x:(x[0], -x[1]))
for d in data:
    print(d[2] + 1)

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

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

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

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

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

ls.sort()
for l in ls:
    print(l[2])

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

li=[]

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


new_li=sorted(li,key=lambda x:x[2] , reverse=True)
new2_li=sorted(new_li,key=lambda x:x[1])


for j in range(0,n):
  print(new2_li[j][0])

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

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

X.sort()

for i in range(0,N-1):
    for j in range(i+1,N):
        if X[i][0]==X[j][0]:
            if X[i][1]<X[j][1]:
                tmp=X[i]
                X[i]=X[j]
                X[j]=tmp

for i in range(0,N):
    print(X[i][2])

Solution (Python):
n = int(input())
dct_id = {}
dct_city = {}
cities = []
for i in range(n):
  tmp = input()
  city = tmp.split()[0]
  score = int(tmp.split()[1])
  dct_id[score] = i+1
  
  if city not in dct_city.keys():
    dct_city[city] = [score]
  else:
    dct_city[city].append(score)
  cities.append(city)
cities = list(set(cities))
cities.sort()

for city in cities:
  
  score_list = dct_city[city]
  score_list.sort(reverse=True)
  
  for score in score_list:
    print(dct_id[score])

Solution (Python):



N, *SP = [s.split() for s in open(0)]
SP = {(s[0], int(s[1])):index for index, s in enumerate(SP)}

SP_values = list(SP.keys())


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


for i in SP_values:
    print(int(SP[i])+1)

Solution (Python):
n = int(input())
w = [input().split() for _ in range(n)]
print("\n".join(str(w.index(i) + 1) for i in sorted(w, key=lambda wi: (wi[0], -int(wi[1])))))

Solution (Python):
n=int(input())
d=[]
ans=[[]for i in range(n)]
for i in range(n):
  d.append(list(input().split()))
for i in range(n):
  ans[i].append(d[i][0])
  j=int(d[i][1])
  ans[i].append(-j)
  ans[i].append(i)
ans.sort()

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10000)
INF = 1<<32


def solve(N: int, S: "List[str]", P: "List[int]"):
    sp = [[i, S[i], P[i]] for i in range(N)]

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

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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = [str()] * (N)  
    P = [int()] * (N)  
    for i in range(N):
        S[i] = next(tokens)
        P[i] = int(next(tokens))
    solve(N, S, P)

if __name__ == '__main__':
    main()

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

for j in range(n):
  s[j].append(j+1)

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

for k in range(n):
  print(num[k][2])

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

dat = []

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

dat.sort()

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

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

Solution (Python):
from operator import itemgetter
from operator import attrgetter
N = int(input())
SP = []
for i in range(N):
  s, p = input().split()
  SP.append({"index":i, "S":s, "P":-int(p)})
SP = sorted(SP, key = itemgetter("S", "P"))
for i in range(N):
  print("{}".format(SP[i]["index"]+1))

Solution (Python):
N = int(input())
S = [0] * N
P = [0] * N
restaurant= []
for i in range(N):
  S[i], P[i] = input().split()

for i in range(N):
  restaurant.append([i+1, S[i], int(P[i])])

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

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

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


if __name__ == '__main__':
    main()

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

sorted_items = sorted(
  SP,
  key = lambda sp: (sp[0], -1 * sp[1])
)
for item in sorted_items:
	print(item[2])

Solution (Python):
N = int(input())
l = [input().split() for _ in range(N)]
a = [[x[0], -int(x[1])] for x in l]

ans = sorted(a)

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

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

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

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

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

for i in range(n):
    score_list.append(list(input().split() +[str(i+1)]))
    score_list[i][1] = 100 - int(score_list[i][1])
score_list.sort()
for i in range(n):
    print(score_list[i][2])

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

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

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

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

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

for i in range(n):
    list1.append(list(input().split() + [str(i+1)]))
    list1[i][1] = 100 - int(list1[i][1])

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

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

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

X.sort()

for i in range(0,N-1):
    for j in range(i+1,N):
        if X[i][0]==X[j][0]:
            if X[i][1]<X[j][1]:
                tmp=X[i]
                X[i]=X[j]
                X[j]=tmp

for i in range(0,N):
    print(X[i][2])

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

w_list = [[0]*n]*n

for i in range(n):
  w_list[i] = input().split()
  w_list[i].append(i+1)
  
w_list.sort(key = lambda l: (l[0], -int(l[1])))
print(*[w[-1] for w in w_list], sep  = '\n')

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

for i in range(0,N):
  L[i][1] = 100-int(L[i][1])
  L[i].append(i+1)
L.sort()



for j in range(0,N):
  print(L[j][2])

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

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

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

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

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

for i in range(N):
    L[i].append(i+1)
    
for _ in range(N):
    idx = 0
    temp = L[0]
    ans = 0
    while idx < len(L):
        if temp[0] > L[idx][0]:
            ans = idx
            temp = L[idx]
        elif temp[0] == L[idx][0] and int(temp[1]) < int(L[idx][1]):
            ans = idx
            temp = L[idx]
        idx += 1
    ans_list = L.pop(ans)
    print(ans_list[2])

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

x = []

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

x.sort()

for i in range(n) :
    print(x[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+1))
x.sort()
for i in range(N):
    print(x[i][2])

Solution (Python):
N=int(input())
S=[]
for i in range(N):
    S.append(list(input().split()))
    S[i][1]=-int(S[i][1])
for i in range(N):
    print(sorted(range(N),key=lambda k : S[k])[i]+1)

Solution (Python):
from operator import itemgetter

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

for n in range(N):
    X.append([n+1])

for n in range(N):
    s, p = map(str, input().split())
    S.append(s)
    P.append(int(p))

for n, m in enumerate(S):
    X[n].append(m)

for n, m in enumerate(P):
    X[n].append(m)

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

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

Solution (Python):
N = int(input())
r = []
for i in range(1,N+1):
    s, p = input().split()
    r.append((i,s,int(p)))
r.sort(key = lambda x: "{}{:03}".format(x[1],100-x[2]))
for i in r:
    print(i[0])

Solution (Python):
N = int(input())
lst = []
for i in range(N):
	a, b = map(str, input().split())
	lst.append([a, int(b), i+1])

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

for i in range(N):
	print(lst[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):
List=[]
n=int(input())
for i in range(n):
    a,b=input().split()
    List.append([a,int(b),i+1])
List=sorted(List, key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(List[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(reverse=False)

x=100
for i in sp:
    i.insert(1,x)
    x-=1
    

sp.sort(reverse=False)

for i in sp:
    print(i[3])

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

for i in range(n):
    R[i].append(i+1)

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
SP = [(x.split()[0].decode('utf-8'),int(x.split()[1])) for x in readlines()]

SP = sorted((name,-pt,i+1) for i,(name,pt) in enumerate(SP))

answer = '\n'.join(str(x[2]) for x in SP)
print(answer)

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

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

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

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

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

for l in range(0,N):
	L.append(input().split())
	L[l][1] = (abs(int(L[l][1])-10**10),l+1)

L = sorted(L)

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

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

for i, j in enumerate(restran):
    restran[i][1] = int(restran[i][1])
    restran[i].append(i+1)

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

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

Solution (Python):
from operator import itemgetter

n = int(input())
s = []; p = []; c = []
for i in range(n):
    s0, p0 = input().split()
    c.append(i); s.append(s0); p.append(int(p0))

ans = list(zip(s, p, c))
ans.sort(key=itemgetter(1), reverse=True)
ans.sort(key=itemgetter(0))


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

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

Solution (Python):
n=int(input())
L=[]
for i in range(n):
      a,b=input().split()
      L.append((i,a,int(b)))
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]+1)

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

Solution (Python):
from sys import stdin

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

li = [list(stdin.readline().rstrip().split()) for _ in range(n)]

for i in range(len(li)):
    li[i][1] = int(li[i][1])

li2 = sorted(li,key=lambda x:(x[0],x[1]*(-1)))

for s in range(len(li)):
    print(li.index(li2[s])+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 sp:(sp[0],-sp[1]))
for i in sp:print(i[2])

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

Solution (Python):

N = int(input().strip())


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

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())
dic = {}
for i in range(N):
    sp = input().split()
    s = sp[0]
    p = int(sp[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=int(input())
L=[]
for i in range(1,n+1):
      a,b=input().split()
      L.append((i,a,int(b)))
      
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 = [input().split() for _ in range(n)]


key_li = []
for l in li:
    if l[0] not in key_li:
        key_li.append(l[0])
dict = {}
sorted_ki = sorted(key_li)
for i,s in enumerate(sorted_ki):
    dict[i] = []
    for j,l in enumerate(li):
        if s == l[0]:
            dict[i].append([int(l[1]),j])
fin_li = []
for k in range(len(dict)):
    each_li = []
    for d in dict[k]:
        if d not in each_li:
            each_li.append(d[0])
    s_e_li = sorted(each_li, reverse=True)
    for s_e in s_e_li:
        for d in dict[k]:
            if s_e == d[0]:
                fin_li.append(d[1]+1)
for f in fin_li:
    print(f)

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

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

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


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

for i in range(n):
    x[i][1] = int(x[i][1])

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

for i in range(n):
    print(x.index(test2[i]) + 1)

Solution (Python):
from sys import stdin
from operator import itemgetter

def list_align(l):
    try :
        return int(l) * -1
    except:
        return l

n = int(stdin.readline().rstrip())
shops = [list(map(lambda x:list_align(x), stdin.readline().rstrip().split())) + [i+1] for i in range(n)]
shops.sort()
for i in range(n):
    print(shops[i][2])

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

Solution (Python):
from operator import itemgetter

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

A = zip(idx,S,P)
A = sorted(A, key=itemgetter(2),reverse=True)
A = sorted(A, key=itemgetter(1))

idx, S, P = zip(*A)

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

Solution (Python):
n = int(input())
L = [list(input().split()) for _ in range(n)]
L2 = sorted(L)
L3 = [i[0] for i in L2]
L4 = list(set(L3))
L4.sort()
L5 = []
L6 = []
for k in L4:
  s = []
  for v in L2:
    if v[0]==k:
      s.append(int(v[1]))
  s = sorted(s, key=int, reverse=True)
  for t in s:
    L5.append(str(t))
for i in range(n):
  L6.append([L3[i],L5[i]])
for u in L6:
  print(L.index(u)+1)

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
sp = [ list(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[1],reverse=True)


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


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

Solution (Python):

N = int(input())
book = []
for i in range(N):
    s , p = input().split()
    book.append([s,int(p),i + 1])
if N == 1:
    print(1)
    exit()
book.sort()
tmp_name = book[0][0]
tmp_list = []
tmp_list.append(book[0])

for i in range(1,N):
    if book[i][0] == tmp_name:
        tmp_list.append(book[i])
    else:
        tmp_list.sort(key = lambda x: -x[1])
        for j in tmp_list:
            print(j[2])
        tmp_name = book[i][0]
        tmp_list = []
        tmp_list.append(book[i])
    if i == N - 1:
        tmp_list.sort(key=lambda x: -x[1])
        for j in tmp_list:
            print(j[2])

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

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

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

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

lista=[]

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

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


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


ans=0
list_ans=[]
for i in range(n):
	ans=lista[i][2]
	list_ans.append(ans)

for i in range(n):
	print(list_ans[i])

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

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

Solution (Python):
N=int(input())
V=[]
for i in range(N):
    a,b=map(str,input().split())
    U=[a,-int(b),i]
    V.append(U)

V.sort()
for _,_, i in V:
    print(i+1)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    s = [
        [-int(i) if i.isdigit() else i for i in input().split()] + [j]
        for j in range(1, n + 1)
    ]
    for _, _, i in sorted(s):
        print(i)


if __name__ == "__main__":
    main()

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

for i in range(N):
    s,p=map(str,input().split())
    p=-1*int(p)
    A.append([s,p,i+1])

A.sort()

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

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

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

Solution (Python):
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    RVS = [input().rstrip().split(' ')+[i+1] for i in range(N)]
    RVS = [(x[0],int(x[1]),x[2]) for x in RVS]
    RVS.sort(key=itemgetter(1), reverse=True)
    RVS.sort(key=itemgetter(0))
    for x in RVS:
        print(x[2])

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40"""
        output = """3
4
6
1
5
2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """10
yakutsk 10
yakutsk 20
yakutsk 30
yakutsk 40
yakutsk 50
yakutsk 60
yakutsk 70
yakutsk 80
yakutsk 90
yakutsk 100"""
        output = """10
9
8
7
6
5
4
3
2
1"""
        self.assertIO(input, output)
def resolve():
    n=int(input())
    towns=[]
    for i in range(n):
        x=input().split()
        towns.append([x[0],-int(x[1]),i+1])
    towns.sort()
    for i in towns:
        print(i[2])

if __name__ == "__main__":
    resolve()