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

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import reduce,lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(1,len(s)+1), key=lambda k: s[k-1])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    N = int(input())
    
    
    
    
    l=[]
    for _ in range(N):
        s,n=input().split()
        n=int(n)
        l.append((s,-n))
    li=argsort(l)
    printl(li)






if __name__ == "__main__":
    main()

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

for i in range(len(s_list)):
  for j in reversed(range(i+1, len(s_list))):
    if s_list[j-1][0] == s_list[j][0] and int(s_list[j-1][1]) < int(s_list[j][1]):
      s_list[j-1], s_list[j] = s_list[j], s_list[j-1]

for s in s_list:
  for index,sc in enumerate(score):
    if s == sc:
      print(index+1)

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_,  = input().split()
  sp.append([s_, int(p_)])

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

for i in range(n):
  print(sp1.index(sp2[i])+1)

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

Solution (Python):
n=int(input())
res = []
for i in range(n):
    s,p=map(str, input().split())
    res += [(s,int(p))]
res1=res
res = sorted(res, key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(res1.index(res[i])+1)

Solution (Python):
import numpy as np
N = int(input())
List = [[]]*N
for T in range(0,N):
    Str,Num = input().split()
    List[T] = [Str,int(Num),T+1]
SorL = sorted(List, key=lambda x:(x[0],-x[1]))
SorI = list(str(x[2]) for x in SorL)
print('\n'.join(SorI))

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

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

X.sort()
for (_,_,c) in X:
    print(c)

Solution (Python):
n=int(input())
res = []
for i in range(n):
    s,p=map(str, input().split())
    res += [(s,int(p))]
res1=res
res = sorted(res, key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(res1.index(res[i])+1)

Solution (Python):
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
from operator import mul

INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)



class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def dijkstra_heap(s, edge, n):
    
    d = [10**20] * n
    used = [True] * n 
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


def combinations_count(n, r):
    if n < r:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def lcm(x, y):
    return (x * y) // gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers, 1)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True



def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P


def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


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

Solution (Python):
n=int(input())
res = []
for i in range(n):
    s,p=map(str, input().split())
    res += [(s,int(p))]
res1=res
res = sorted(res, key=lambda x:(x[0],-x[1]))
for i in range(n):
    print(res1.index(res[i])+1)

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

for n in range(N):
  s,p = input().split()
  R.append((s,-int(p),n+1))
  
for s,p,n in sorted(R):
  print(n)

Solution (Python):
N  = int(input())
rs = [ [ *input().split(), n ] for n in range(N) ]

rs = sorted(
    [ (f'{s}{100 - int(p):03}', i + 1) for s, p, i in rs ],
    key=lambda t: t[0],
)

for r in rs:
    print(r[1])

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

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

s = sorted(l, key=lambda i: (i[0], -i[1]))

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

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

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

for i in range(n):
    print(a[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):
R=list()
n=0
s=list()
p=list()
N=int(input())
for i in range(N):
  S,P=input().split()
  P=int(P)
  s.append([S,100-P,i+1])
  p.append(P)
  n=S
s=sorted(s)
for i in range(N):
  print(s[i][2])

Solution (Python):
N = int(input())
T = [input().split() for _ in range(N)]
T = [(i, t[0], int(t[1])) for i, t in enumerate(T, 1)]

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

Solution (Python):
R=list()
n=0
s=list()
p=list()
N=int(input())
for i in range(N):
  S,P=input().split()
  P=int(P)
  s.append([S,100-P,i+1])
  p.append(P)
  n=S
s=sorted(s)
for i in range(N):
  print(s[i][2])

Solution (Python):
N = int(input())
city={}
city_name=[]
for n in range(N):
    S = input().split()
    city[n+1]=S
    city_name.append(S[0])

city_name=list(set(city_name))
city_name.sort()

for c_name in city_name:
    city_temp = {}
    for c_key in city.keys():
        if city[c_key][0] == c_name:
            city_temp[int(city[c_key][1])]=c_key
            
    p_temp = list(city_temp.keys())
    p_temp.sort(reverse=True)
    for v in p_temp:
        print(city_temp[v])

Solution (Python):
from operator import itemgetter
n = int(input())
dic = {}
for i in range(1, n + 1):
  s, p = input().split()
  p = int(p)
  dic.setdefault(s, [])
  dic[s].append((i, p))
cities = sorted(list(dic.keys()))
for c in cities:
  dic[c].sort(key=itemgetter(1), reverse=True)
  for i in dic[c]:
    print(i[0])

Solution (Python):
def main():
    n = int(input())
    inlis = []
    namelis = []
    for i in range(n):
        a, b = map(str, input().split())
        b = int(b)
        inlis.append([a,b])
        namelis.append(a)
    namelis.sort()    
    inlis_so = sorted(inlis)
    anslis = []
    for num in inlis:
        
        kazu = namelis.count(num[0])
        if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
    for i in range(1, n+1):
        
        print(anslis.index(i)+1)

    

        
    
if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

n = int(input())

r = []

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

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

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

Solution (Python):

n = int(input())
e = sorted([[str(i + 1)] + input().split() for i in range(n)],
           key=lambda x: int(x[2]),
           reverse=True)
d = dict()
for i in e:
    if i[1] not in d:
        d[i[1]] = []
    d[i[1]].append(i[0])
e = sorted(d.items(), key=lambda x: x[0])
for i in e:
    print(*i[1], sep="\n")

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

r = []

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

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

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

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

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

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

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

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

for i in new_lis:
    print(lis.index(i) + 1)

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

restaurants = {}
for i in range(1, N+1):
    s, p = input().split()
    restaurants[i] = (s, int(p) * -1)

key = lambda x: (x[1][0], x[1][1])
restaurants_sorted = sorted(restaurants.items(), key=key)

for k in restaurants_sorted:
    print(k[0])

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

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

key = lambda x: x[1]
restaurants_sorted = sorted(restaurants.items(), key=key)

city_restraurant = []
city = ""
for restaurant in restaurants_sorted:
    if not city:
        city = restaurant[1][0]
        city_restraurant.append((restaurant[0], restaurant[1][1]))
    elif city == restaurant[1][0]:
        city_restraurant.append((restaurant[0], restaurant[1][1]))
    else:
        city_restraurant.sort(key=lambda x: x[1], reverse=True)
        for c in city_restraurant:
            print(c[0])
        city_restraurant = [(restaurant[0], restaurant[1][1])]
        city = restaurant[1][0]
city_restraurant.sort(key=lambda x: x[1], reverse=True)
for c in city_restraurant:
    print(c[0])

Solution (Python):
n=int(input())
cnt=1
List=[]
for i in range(n):
    s,p=input().split()
    p=int(p)
    List.append([s,p,cnt])
    cnt+=1
List.sort()
for i in range(len(List)):
    for j in range(i+1,len(List)):
        if List[i][0]==List[j][0] and List[j][1]>=List[i][1]:
            List[i],List[j]=List[j],List[i]
for i in range(len(List)):
    print(List[i][2])

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

n=[]
for _ in range(a):
    o,q=map(str,input().split())
    n.append([o,int(q)])

m=sorted(n)
m.sort(key=lambda x: (x[0],-x[1]))

for i in m:
    print(n.index(i)+1)

Solution (Python):
from operator import itemgetter

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

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

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

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

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

Solution (Python):
n = int(input())
sp = [0] * n
for i in range(n):
    sp[i] = list(map(str,input().split()))
sp_sorted = sorted(sp, key=lambda x: int(x[1]), reverse=True)
sp_sorted_sorted = sorted(sp_sorted, key=lambda x: x[0])
for i in range(n):
    for j in range(n):
        if sp_sorted_sorted[i] == sp[j]:
            print(j+1)

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

Solution (Python):
n = int(input())
city = []
nums = []
result = []
 
for i in range(n):
  s,p = input().split()
  p = int(p)
  city.append(s)
  nums.append(p)
  result.append([s,p,i+1])
 
for i in sorted(set(city)):
  for j in sorted(set(nums), reverse = True):
    for k in result:
      if k[0] == i and k[1] == j:
        print(k[2])

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

Solution (Python):
N = int(input())
SP = []
for i in range(N):
    s, p = input().split()
    p = int(p)
    SP.append(list([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())
a=[]
for i in range(N):
    s,p=input().split()
    p=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=input().split()
    p=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):
    a.append(list(input().split()))
b = a
for i in range(n):
    b[i][1] = -int(b[i][1])
b = sorted(b)
for i in range(n):
    b[i][1] = -b[i][1]
    print(a.index(b[i])+1)

Solution (Python):
n = int(input())
city = []
nums = []
result = []

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

for i in sorted(set(city)):
  for j in sorted(set(nums), reverse = True):
    for k in result:
      if k[0] == i and k[1] == j:
        print(k[2])

Solution (Python):
N = int(input())
line = []
for i in range(N):
    tmp = [j for j in input().split()]
    tmp[1] = -1 * int(tmp[1])
    tmp.append(i + 1)
    line.append(tmp)
line.sort()
for i in range(N):
    print(line[i][2])

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

Solution (Python):
def INT():
    return int(input())

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

def LI():
    return list(map(int, input().split()))

N = INT()
ans = {}

for i in range(N):
    S, P = input().split()
    P = int(P)
    
    if S in ans.keys():
        ans[S].append([P, i + 1])
        ans[S].sort(key = lambda x : x[0], reverse = True)
    else:
        ans[S] = [[P, i + 1]]
    
store = list(ans.keys())
store.sort()

for s in store:
    for p in ans[s]:
        print(p[1])

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

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

Solution (Python):


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

for i in range(n):
    tp = list(input().split())
    s.append(tp)

for i in range(n):
    s[i][1] = int(s[i][1]) * (-1)
    s[i].append(i+1)
s.sort()

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

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

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

name = list(sorted(set(S)))

for i in range(len(name)):
    score = []
    number = []
    for j in range(N):
        if S[j] == name[i]:
            score.append(P[j])
            number.append(j+1)
    for k in range(S.count(name[i])):
        place = score.index(max(score))
        print(number[place])
        del number[place]
        del score[place]

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

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

Solution (Python):
from collections import defaultdict

N = int(input())
SP = sorted([list(input().split()) + [i + 1] for i in range(N)])

d = defaultdict(list)

for s, p, i in SP:
    d[s].append((int(p), i))

ans = []

for k, v in d.items():
    v = sorted(v)[::-1]
    for i, j in v:
        ans.append(str(j))

print('\n'.join(ans))

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

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

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

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

lis = [k for k in lis]

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


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

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

Solution (Python):
n = int(input())
ans = [0]*n
for i in range(n):
    a, b = map(str, input().split())
    b = int(b)
    ans[i] = [i+1, a, b]
ans.sort(key=lambda x: (x[1], -x[2]))
for j in ans:
    print(j[0])

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

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

for i in range(N):
    name, score = map(str, input().split())
    restaurants.append([name, int(score), i+1])

sorted_restaurants = restaurants.copy()
sorted_restaurants = sorted(sorted_restaurants, key=lambda x: (x[0], -x[1]))

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

Solution (Python):
num = int(input())
arr = []
for i in range(0, num):
  enter = input().split()
  arr.append(tuple((enter[0], int(enter[1]), i+1)))
             
sorted_by_score = sorted(arr, key = lambda x: x[1], reverse=True)
sorted_by_name = sorted(sorted_by_score, key = lambda x: x[0])
for i in sorted_by_name:
  print(i[2])

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

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

ans = [i[2] for i in sp]

print(*ans)

Solution (Python):
from sys import stdin
N = int(input())
L =[stdin.readline().split() for _ in range(N)]
for n in range(N):
  L[n][1] = int(L[n][1])
for n in range(N):
  L[n].append(n)
L = sorted(L, reverse=True, key=lambda x: x[1])
L = sorted(L, reverse=False, key=lambda x: x[0]) 
for n in range(N):
  print(L[n][2]+1)

Solution (Python):
from sys import stdin
N = int(input())
L =[stdin.readline().split() for _ in range(N)]
for n in range(N):
  L[n][1] = int(L[n][1])
for n in range(N):
  L[n].append(n)
L = sorted(L, reverse=True, key=lambda x: x[1])
L = sorted(L, reverse=False, key=lambda x: x[0])
for n in range(N):
  print(L[n][2]+1)

Solution (Python):
from sys import stdin
N = int(input())
L =[stdin.readline().split() for _ in range(N)]
for n in range(N):
  L[n][1] = int(L[n][1])
for n in range(N):
  L[n][1] = -L[n][1]
for n in range(N):
  L[n].append(n)
L1 = sorted(L, reverse=False, key=lambda x: x[1])
L2 = sorted(L1, reverse=False, key=lambda x: x[0])
for n in range(N):
  print(L2[n][2]+1)

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

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


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



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

Solution (Python):






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





mylist = sorted(sp, key=lambda x: x[2], reverse=True)
mylist = sorted(mylist, key=lambda x: x[1])
for i in range(len(mylist)):
    print(mylist[i][0]+1)

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

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

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

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

Solution (Python):
import sys
import itertools

import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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


for r in rs:
    print(r[2] + 1)

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

for i in range((N-1)+1):
  X=input()
  S, P = map(str, X.split())
  list1.append((i+1, S, int(P)))

list2 = sorted(list1, key=lambda x:(x[1], -x[2])) 
for all in list2:
  print(all[0])

Solution (Python):
n = input()
li = []
m = {}
x = set([])
for i in range(int(n)):
      s,p = [z for z in input().split()]
      x.add(s)
      m[str([s,int(p)])] = i
      li.append([s,int(p)])
new = sorted(li, reverse=True)
for i in sorted(list(x)):
      for j in range(int(n)):
            if (new[j][0]==i):
                  print(m[str(new[j])]+1)

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

n = int(readline())

l = []
for i in range(n):
    s, p = readline().decode().rstrip().split()
    p = int(p)
    tmp = [i+1,s,p]
    l.append(tmp)

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

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

for l in lst:
  print(l[0])

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

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

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

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

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

Solution (Python):
def resolve():
    N = int(input())
    ls = []
    for i in range(N):
        tmp = input().split()
        tmp.append(i+1)
        ls.append(tmp)

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

    for l in ls:
        print(l[2])
    return

resolve()

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

Solution (Python):
def solve():
    n = int(input())
    a = []
    for i in range(n):
        key, value = input().split()
        value = -int(value)
        a.append([key, value, i + 1])
    a.sort()
    for i in a:
        print(i[2])
 
 
if __name__ == '__main__':
    solve()

Solution (Python):
import sys
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    A = [0] * N
    for i in range(N):
        s, p = readline().strip().split()
        p = int(p)
        A[i] = (s, p, i + 1)

    A.sort(key=itemgetter(1), reverse=True)
    A.sort(key=itemgetter(0))
    for s, p, i in A:
        print(i)

    return


if __name__ == '__main__':
    main()

Solution (Python):
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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

    for city, points in sorted(d.items()):
        points = sorted(points, reverse=True)
        for _, i in points:
            print(i)

    return


if __name__ == '__main__':
    main()

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


if __name__ == '__main__':
    solve()

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

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

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

Solution (Python):

import sys
input = sys.stdin.readline
N = int(input())
city_point =[]
for i in range(N):
    c,p =input().split()
    city_point.append((c,int(p),i))


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

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