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

Solution (Python):
N = int(input())
a = [0 for _ in range(N)]
for i in range(N):
    S, P = map(str, input().split())
    a[i] = [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(1,n+1):
    s, p = input().split()
    a.append((s, -1*int(p), i))

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

Solution (Python):
n=int(input())
array = []
for i in range(n):
    s,p = input().split()
    array.append([s,100-int(p),i+1])
array.sort()
for i in range(n):
    print(array[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.sort()
for s, p, i in a:
    print(i)

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

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

li=[]
for i in range(n):
    li.append([a[i][0],100- int(a[i][1]), i+1])

li.sort()

for i in range(n):
  print("{}".format(li[i][2]))

Solution (Python):
def guidebook(N: int, scores: list)->list:
    rev = {v: i for i, v in enumerate(scores)}
    scores.sort(key=lambda x: -x[1])
    scores.sort(key=lambda x: x[0])

    return [rev[v]+1 for v in scores]


if __name__ == "__main__":
    N = int(input())
    scores = []
    for _ in range(N):
        s, p = input().split()
        scores.append((s, int(p)))

    for ans in guidebook(N, scores):
        print(ans)

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

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

Solution (Python):

import sys
input = sys.stdin.readline

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

Solution (Python):





N = int(input())
ls = [None]*N
for i in range(N):
    s, p = input().split()
    ls[i] = (i+1, s, int(p))
ls.sort(key=(lambda x: -x[2]))  
ls.sort(key=(lambda x: x[1]))   

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

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

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

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

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

Solution (Python):


n=int(raw_input())
l=[]
for i in xrange(n):
 c,p=map(str,raw_input().split())
 l.append([i+1,c,int(p)])
ll=sorted(l,key=lambda x:(x[1],-x[2]))
for i in xrange(n):
 print ll[i][0]

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

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

sorted_A = sorted(A)

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

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

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

for _ in a:
	_[1] = int(_[1])

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

for index in range(len(a)):
	print(a.index(sorted_a[index])+1)

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

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

ans = [L[i][2] for i in range(N)]

print(*ans, sep="\n")

Solution (Python):
N = int(input())
rest = [tuple(input().split()) for _ in range(N)]
def f1(l):
    s, p = l
    return s
def f2(l):
    s, p = l
    return int(p)
rest2 = sorted(rest, key = f2, reverse = True)
rest2.sort(key = f1)
dict = {}
for i in range(N):
    dict[rest[i]] = i+1
for j in rest2:
    print(dict[j])

Solution (Python):




from sys import stdin
from operator import itemgetter

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

rest_list = []

for i in range(N):
    S, P = [x for x in stdin.readline().rstrip().split()]
    P = int(P)
    rest_list.append([i+1,S,P])


sorted_rest_1 = sorted(rest_list, key=itemgetter(2),reverse=True)
sorted_rest_2 = sorted(sorted_rest_1, key=itemgetter(1))

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

Solution (Python):
N = int(input())
shop_list = [0 for _ in range(N)]
for i in range(N):
    s,p = map(str, input().split())
    p = int(p)
    shop_list[i] = {"no":i+1,"city":s,"points":p}
shop_list.sort(key = lambda x:(x["city"],-x["points"]))
for i in range(N):
    print(shop_list[i]["no"])

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

Solution (Python):
import sys
input = sys.stdin.readline
inf = float('inf')
mod = 10**9+7


def INT_(n): return int(n)-1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [input() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    N = I()
    city = set()
    sp = []
    for i in range(N):
        i += 1
        s, p = input().split()
        p = -int(p)
        sp.append([s, p, i])
    sp.sort()
    for s, p, i in sp:
        print(i)


if __name__ == '__main__':
    main()

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

    city,p=input().split()
    L.append([i+1,str(city),int(p)])

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

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

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

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

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

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

Solution (Python):
n=int(input())
a=[]
b=[i+1 for i in range(n)]
for i in range(n):
  m,l=(j for j in input().split())
  a.append([m,int(l)])
for i in range(n):
  for j in range(n-1):
    if a[j+1][0]<a[j][0] or (a[j+1][0]==a[j][0] and a[j][1]<a[j+1][1]):
                 c=a[j]
                 a[j]=a[j+1]
                 a[j+1]=c
                 d=b[j]
                 b[j]=b[j+1]
                 b[j+1]=d
for i in range(n):
  print(b[i])

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 L:
    print(i)

Solution (Python):

n = int(input())
sp = [None] * n
for i in range(n):
    s, p = input().split()
    sp[i] = [s, -int(p), i + 1]
for x in sorted(sp):
    print(x[2])

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

List = []
for i in range(a):
	b, c = input().split()
	c = int(c)
	List.append([b, -c, i])
List.sort()

for i in range(a):
  print(List[i][2]+1)

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

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

Solution (Python):
from collections import defaultdict
n = int(input())
l1, l2 = [], []
l3 = []
d = defaultdict(dict)

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

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

for i in s_sorted :
    s = sorted(i[1].values(), reverse = True)
    l3.append(s)


for i in range(len(s_sorted)) :
    for k, v in sorted(s_sorted[i][1].items(), key=lambda x: -x[1]) :
        print(k + 1)

Solution (Python):
from operator import itemgetter


a = int(input())
array2 = {}
array99 = []
for i in range(a):
    array = input().split()
    array99.append((array[0], int(array[1]) * -1, i))



b = sorted(array99, key=itemgetter(0, 1))



for i in range(a):
    print(b[i][2] + 1)

Solution (Python):
N = int(input())
name_dict = {}
for i in range(N):
  n, c = input().split()
  c = int(c)
  if n not in name_dict:
    name_dict[n] = [[c, i+1]]
  else:
    name_dict[n].extend([[c, i+1]])

name_dict = sorted(name_dict.items())
for i, value in name_dict:
  value = sorted(value, reverse=True)
  for j in value:
    print(j[1])

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

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

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

from operator import itemgetter
dic1={}
for i in range(len(info)):
    dic1[i+1]=info[i]

info1=sorted(info,key=lambda x:int(x[1]),reverse=True)
info2=sorted(info1,key=itemgetter(0))

for i in info2:
    for key,value in dic1.items():
        if value==i:
            print(key)

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

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

Solution (Python):
import math
def myop1(e):
    return e[1]

def myop2(e):
    return e[0]

t=int(input())
l=[]
d={}
for _ in range(t):
    s,n=input().split(' ')
    n=int(n)
    l.append((s,n))
k=[i for i in l]
l.sort(reverse=True,key=myop1)
l.sort(key=myop2)
for i in range(len(l)):
    d[k[i]]=i
for i in l:
    print(str(d[i]+1))

Solution (Python):
class Rest:

    def __init__(self, idx, city, point):
        self.idx = idx
        self.city = city
        self.point = point

    def __repr__(self):
        return repr((self.idx, self.city, self.point))

    def __lt__(self, other):
        if self.city == other.city:
            return self.point > other.point
        else:
            return self.city < other.city


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

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

Rests.sort()

for i in Rests:
    print(i.idx)

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

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

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

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

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

sps.sort()

for i in range(n):
    print(sps[i][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(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())
a = []

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

a.sort()

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

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

Solution (Python):

def is_int(x):
    try:
        x = int(x)
    except ValueError as e:
        pass
    finally:
        return x

n = int(input())
list = [list(map(is_int,input().split())) for i in range(n)]


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


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


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

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

Solution (Python):

N = int(input())

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

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

Solution (Python):
n = int(input())
sp_array = [[x for x in input().split()]+[index] for index, y in enumerate(range(n))]
tmp = []
for row in sp_array:
    t = [row[0], int(row[1]), int(row[2])]
    tmp.append(t)
res = sorted(tmp, key=lambda x:(x[0],-x[1]))
for row in res:
    print(row[2]+1)

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

sp = sorted(sp)

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

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

list.sort()

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

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

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

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


S.sort()

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

Solution (Python):
import math
from functools import reduce
from collections import deque

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

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

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

for r in reviews:
    print(r[0]+1)

Solution (Python):
import numpy as np
n = int(input())
SP=[]
SPs=[]
for i in range(n):
    SP=[i]
    for j in input().split():
        SP.append(j)
    SPs.append(SP)
SPs=np.array(SPs)

SPs2=SPs[SPs[:,2].astype(int).argsort(kind="mergesort")[::-1],:]
SPs3=SPs2[SPs2[:,1].argsort(kind="mergesort"),:][:,0]

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

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

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

Solution (Python):
N = int(input())
r = {}
for i in range(N):
    Si, Pi = input().split()
    Pi = int(Pi)
    r[(Si, -Pi)] = i + 1

for t in sorted(r.keys()):
    print(r[t])

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

data.sort()

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

Solution (Python):
import math
import numpy as np


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


if __name__ == '__main__':
    main()

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

S.sort()

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

Solution (Python):
from operator import itemgetter
n=int(input())
y,s=list(),list()
for i in range(1,n+1):
	S=input().split()
	S[1]=int(S[1])
	S.append(i)
	s.append(S)
y=sorted(s,key=itemgetter(0))
for i in range(n):
	c=0
	for j in range(1,n):
		if((y[j-1][0]==y[j][0])&(y[j-1][1]<y[j][1])):
			y[j-1],y[j]=y[j],y[j-1]
			c=1
	if c==0:break
for i in range(n):
	print(y[i][2])

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

Solution (Python):
N=int(input())
List=[[0,0,0] for _ in range(N)]
for i in range(N):
    S,P=map(str,input().split())
    List[i][0]=i+1
    List[i][1]=S
    List[i][2]=int(P)
List.sort(key=lambda x:x[2],reverse=True)
List.sort(key=lambda x:x[1])
for i in range(N):
    print(List[i][0])

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

Solution (Python):
import math


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


if __name__ == '__main__':
    main()

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

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

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

for _, _, i in new_SP:
    print(i)

Solution (Python):
from operator import itemgetter
n=int(input())
y,s=list(),list()
for i in range(1,n+1):
	S=input().split()
	S[1]=int(S[1])
	S.append(i)
	s.append(S)
y=sorted(s,key=itemgetter(0))
for i in range(n):
	for j in range(1,n):
		if((y[j-1][0]==y[j][0])&(y[j-1][1]<y[j][1])): y[j-1],y[j]=y[j],y[j-1]
for i in range(n):
	print(y[i][2])

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

rs = [(i + 1, sp[0], int(sp[1])) for i, sp in enumerate(SP)]

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

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

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

scores = []
for i in range(1, n+1):
    c, s = input().split()
    scores.append(("{0}{1}{2:03d}".format(c, "0" * (10 - len(c)), 101 - int(s)), i))

for c, ind in sorted(scores):
    print(ind)

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

Solution (Python):



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

s2=sorted(s,key=lambda x: (x[1]),reverse = True)
s2=sorted(s2,key=lambda x: (x[0]))
for i in s2:
    for j in range(n):
        if i==s[j]:
            print(j+1)

Solution (Python):
N = int(input())
A = []
for i in range(N) :
    S, P = input().split()
    A.append([S])
    A[i].append(100-int(P))
new_A_list = sorted(A)
for i in range(N) :
    print(A.index(new_A_list[i])+1)

Solution (Python):
N=int(input())
Set=[]
for i in range(N):
    a,b=input().split()
    Set.append([a,-int(b),i+1])
A=sorted(Set)

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

Solution (Python):
def input_from_console():
    n = int(input().rstrip())

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


def solve(n, s_list):
    sorted_city_list = sorted(s_list, key=lambda x: (x[1], -x[2]))
    return '\n'.join(map(str, [item[0] for item in sorted_city_list]))


def main():
    n, s_list = input_from_console()
    print(solve(n, s_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  
        check_cases()
    else:
        main()

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

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

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

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

Solution (Python):
n = int(input())
sp = [None]*n
for i in range(n):
    sp[i] = input().split(" ")
sp = list(map(lambda x: [x[0], int(x[1])], sp))
sl = list(map(lambda x: x[0], sp))
sp2 = []
for s in sorted(list(set(sl))):
    l = list(filter(lambda x: x[0] == s, sp))
    sp2.extend(sorted(l, key=lambda x:x[1], reverse=True))
for x in sp2:
    print(sp.index(x)+1)

Solution (Python):








n=int(input())
sp={}
for i in range(n):
    li=input().split()
    li.append(i+1)
    li[1]=int(li[1])
    if li[0] not in sp:
        sp[li[0]]=[li]
    else:
        sp[li[0]].append(li)
        sp[li[0]].sort(reverse=True)
items_sorted = sorted(sp.items())

for i in range(len(items_sorted)):
    for j in range(len(items_sorted[i][1])):
        print(items_sorted[i][1][j][2])

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

S.sort()

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

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

Solution (Python):
read = input
N = int(read())
guidebook = {}
for i in range(1,N+1):
    n,s = read().split()
    s = int(s)
    if n not in guidebook:
        guidebook[n] = {}
    guidebook[n][s] = i
guidebook = list(guidebook.items())
guidebook.sort()
for n,d in guidebook:
    B = list(d.items())
    B.sort(reverse = True)
    for s,i in B:
        print(i)

Solution (Python):
n = int(input())
rest = {}
for i in range(n):
  s, p = input().strip().split()
  if s in rest:
    rest[s].append((int(p), i))
  else:
    rest[s] = [(int(p), i)]

for k, v in sorted(rest.items(), key=lambda x: x[0]):
  for _, i in sorted(v, key=lambda x: -x[0]):
    print(i+1)

Solution (Python):
N = int(input())
res_list=[]
for i in range(N):
    a,b = input().split()
    b = int(b)
    res_list.append([i+1,a,b])
res_list =sorted(res_list, key=lambda x: x[1])
tes_list=[]
for i in range(N):
    if tes_list == []:
        tes_list.append(res_list[i])
    if i == N-1:
        tes_list = sorted(tes_list, key=lambda x: x[2],reverse=True)
        for j in range(len(tes_list)):
            print(tes_list[j][0])
    else:
        if res_list[i][1] == res_list[i+1][1]:
            tes_list.append(res_list[i+1])
        else:
            tes_list = sorted(tes_list, key=lambda x: x[2],reverse=True)
            for j in range(len(tes_list)):
                print(tes_list[j][0])
            tes_list=[]

Solution (Python):
n = int(input())
sp = [None]*n
for i in range(n):
    sp[i] = [input().split(" "), i+1]
sp = list(map(lambda x: [[x[0][0], int(x[0][1])], x[1]], sp))
sl = list(map(lambda x: x[0][0], sp))
sp2 = []
for s in sorted(list(set(sl))):
    l = list(filter(lambda x: x[0][0] == s, sp))
    sp2.extend(sorted(l, key=lambda x:x[0][1], reverse=True))
for x in sp2:
    print(x[1])

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):
from collections import OrderedDict

N = int(input())
X = {}
tmp1 = []
for i in range(N):
    tmp1.append(input())
    tmp2 = tmp1[i].split()
    if tmp2[0] in X:
        X[tmp2[0]].append(int(tmp2[1]))
    else:
        X[tmp2[0]] = [int(tmp2[1])]

X_sorted = OrderedDict(sorted(X.items(), key=lambda x:x[0]))
for i in X_sorted.keys():
    X_sorted[i] = sorted(X_sorted[i],reverse=True)

res = []
for i in X_sorted.keys():
    for j in range(len(X_sorted[i])):
        res.append(i+" "+str(X_sorted[i][j]))

for i in range(len(res)):
    print(tmp1.index(res[i])+1)

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

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

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

S.sort()

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

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

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

Solution (Python):



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

nsp.sort()

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

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

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

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

Solution (Python):
from operator import itemgetter
N = int(input())
SP = []
for i in range(N):
    name,cost = [x for x in input().split()]
    SP.append([name,int(cost),i])
SP.sort(key=itemgetter(1),reverse=True)
SP.sort(key=itemgetter(0))
for i in SP:
    print(i[2]+1)

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

Solution (Python):

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

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

Solution (Python):
import numpy as np
from operator import itemgetter
 
N = int(input())
 
list = []
for i in range(N):
    a,b=input().split()
    list.append([a, int(b),i+1])
sort1 = sorted(list, key=itemgetter(0))
if N == 1:
  	print(1)
else:
    ans = []
    kari = []
    end = 1
    k = 1
    for i in range(0,N-1):
        if end == 1:
            kari.append(sort1[i])
        else:
            k = 0
        if sort1[i][0] == sort1[i+1][0]:  
            kari.append(sort1[i+1])
            end = 0
            if i+1 > N-2:
            	kari.sort(key=itemgetter(1),reverse=True)
            	ans.extend(kari)

        else:
            kari.sort(key=itemgetter(1),reverse=True)
            ans.extend(kari)
            if i+1 > N-2:
            	ans.append(sort1[i+1])
            kari = []
            end = 1
    
    for i in range(0,len(ans)):
        print(ans[i][2])

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

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

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

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

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

Solution (Python):
N = int(input())
L = [[]*3]*N
S = ''
P = ''
for i in range(N):
  S, P = input().split()
  L[i] = [S, int(P)*-1, i+1]

L.sort()

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

Solution (Python):
N = int(input())
location = []
sorted_location = []
score = []

for i in range(N):
	a, b = input().split()
	location.append(a)
	score.append(int(b))




sorted_location = location[:]
sorted_location.sort()



a = [] 
for i in range(N):
	
	l = location[i]
	s = score[i]




	
	score_num = [j for j, x in enumerate(location) if x == l]
	score_list = []
	for j in score_num:
		score_list.append(score[j])
	score_list.sort(reverse=True)


	
	
	loc1 = sorted_location.index(l) + 1


	
	loc2 = score_list.index(s)


	
	a.append(loc1 + loc2)


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

Solution (Python):

import os
import time
import re
import math


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

SP=sorted(SP, key=lambda x:(x[1]), reverse=True)
SP=sorted(SP, key=lambda x: x[0])
for a in range(N):
    print(SP[a][2])

Solution (Python):
from operator import itemgetter

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

SP=sorted(SP,key=itemgetter(1),reverse=True)
SP = sorted(SP,key=itemgetter(0))

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

Solution (Python):



import collections

n = int(input())

rest = [list(input().split()) for i in range(n)]
rest_hash = collections.OrderedDict()



for i in range(len(rest)):
    rest[i].append(i+1)


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


for i in range(len(rest)):
    if rest[i][0] in rest_hash:
        rest_hash[rest[i][0]].append(list([rest[i][1], rest[i][2]]))
    else:
        rest_hash[rest[i][0]] = [[rest[i][1], rest[i][2]]]



for n in rest_hash:
    for element in reversed(rest_hash[n]):
        print(element[1])

Solution (Python):
n=int(input())
cityLst=[]
for i in range(n):
	s,p=map(str,input().split(" "))
	cityLst.append(["{:<10}".format(s),p])
sCityLst=sorted(cityLst,key=lambda x:x[0]+"a"+chr(-1*(int(x[1])-100)+97))
for o in sCityLst:
	print(cityLst.index(o)+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)