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())
p=1
S=[]
A=[]
U=[]
T=[]
L= [list(map(str,input().split())) for i in range(N)]
for j in range(1,N+1):
  L[j-1].append(j)
L.sort(key=lambda x: x[0])

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

T.append(L[0][0])
for i in range(1,N):
  if L[i-1][0]!=L[i][0]:
    T.append(L[i][0])

for j in range(len(T)):
  for k in range(N):
    if S[k][0]==T[j]:
      A.append(S[k][2])
for i in range(N):
  print(A[i])

Solution (Python):
N=int(input())
A=[]
for i in range(N):
  s,p=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],reverse=False)
for i in range(N):
  print(A[i][2])

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

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

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

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

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

Solution (Python):
N = int(input())
def f(x): return (x[0], -int(x[1]))
SP = [(f(input().split()), i) for i in range(1, N+1)]
SP.sort()
for _, i in SP:
    print(i)

Solution (Python):


n = int(input())
sp = ["" for _ in range(n)]

for i in range(n):
    a, b = map(str, input().split())
    sp[i] = [a, int(b)]
    sp[i].insert(2, i+1)


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


sp3 = sorted(sp2, key=lambda x:x[0], reverse=False)


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

Solution (Python):
from collections import namedtuple
from operator import attrgetter


Restaurant = namedtuple("Restaurant", ("id", "city", "score"))
restaurants = []
N = int(input())
for i in range(N):
    s, p = input().split()
    restaurant = Restaurant(i+1, s, int(p))
    restaurants.append(restaurant)
for restaurant in sorted(sorted(restaurants, key=attrgetter("score"), reverse=True), key=attrgetter("city")):
    print(restaurant.id)

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

l=[]
a=[]
b=[]
d={}
s=[]

for i in range(1,n+1):
    t=list(input().split())
    l.append([t[0],int(t[1])])
    if t[0] not in a:
        a.append(t[0])
    b.append(t[0])
c=l.copy()
for e in a:
    d[e]=b.count(e)
c.sort()
i=0
while i<n:
    if d[c[i][0]]==1:
        s.append(l.index(c[i])+1)
        i+=1
    else:
        for j in range(d[c[i][0]]):
            s.append(l.index(c[i+d[c[i][0]]-1-j])+1)
        i+=d[c[i][0]]

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

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

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

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

for a in sp:
    print(sp2idx[tuple(a)])

Solution (Python):
N, *L,  = [s.split() for s in open(0)]
d = {(L[i][0], -int(L[i][1])): i for i in range(len(L))}

d = sorted(d.items())
for i in d:
    print(i[1]+1)

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

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

sorted_list = sorted(sp_list, key=lambda x: x[2], reverse=True)
sorted_list2 = sorted(sorted_list, key=lambda x: x[1])
for i in range(N):
    print(sorted_list2[i][0])

Solution (Python):
n = int(input())
sp = [[i+1]+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 i in sp:
    print(i[0])

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

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

for x in sp:
    print(x[0])

Solution (Python):
n = int(input())
sp = [[i+1]+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 x in sp:
    print(x[0])

Solution (Python):
from operator import itemgetter


def solve():
    N = int(input())
    SP = [['', 0, 0] for _ in range(N)]
    for i in range(N):
        S, P = map(str, input().split())
        P = -int(P)
        SP[i] = [S, P, i+1]
    
    SP.sort(key=itemgetter(0, 1))
    for i in range(N):
        print(SP[i][2])


if __name__ == '__main__':
    solve()

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

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

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

c = s.copy()
s.sort()
s.append("fin")

cnt = 0
for i in range(n):
    if (s[i][0] != s[i + 1][0]):
        for j in reversed(range(i - cnt, i + 1)):
            for k in range(n):
                if s[j][1] == c[k][1]:
                    print(k + 1)
                    break
        cnt = 0
    else:
        cnt += 1

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

Solution (Python):

import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    isp = [(i+1,S[i],P[i]) for i in range(N)]
    isp.sort(key= lambda x: (x[1],-x[2]))
    for t in isp:
        print(t[0])
    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())
L=[list(input().split()) for i in range(n)]
for i in range(n):
    L[i][1]=-int(L[i][1])
    L[i].append(i+1)
L.sort()
for i in range(n):
    print(L[i][2])

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

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

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

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

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

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

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

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

for i in range(N):
    for j in range(N):
        if sort_xy[i][0] == xy[j][0]:
            if sort_xy[i][1] == xy[j][1]:
                print(j + 1)

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

for g in sorted(sorted(guide, key = lambda x: x[1], reverse = True), key = lambda x: x[0]):
    print(g[2])

Solution (Python):
n = int(input())
d = dict()
name_list = []
for j in range(n):
    s, i = input().split()
    if s not in d.keys():
        d[s] = []
    d[s].append([int(i), j])
    name_list.append(s)
name_list = list(set(name_list))
name_list.sort()
for t in name_list:
    tar = sorted(d[t], reverse=True)
    for ans in tar:
        print(ans[1] + 1)

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

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

Solution (Python):
N = int(input())
city_dict = {}
for i in range(N):
  S, P = input().split()
  if S in city_dict:
    city_dict[S].append({'num' : i, 'score' : int(P)})
    continue
  city_dict[S] = [{'num' : i, 'score' : int(P)}]
  
for city in sorted(city_dict):
  sorted_city_list = sorted(city_dict[city], key=lambda x : x['score'], reverse = True)
  for node in sorted_city_list:
    print(node['num']+1)

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

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

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

[print(lst[i][2]) for i in range(n)]

Solution (Python):

n = int(input())

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

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

Solution (Python):
from collections import defaultdict

N = int(input())
SP = defaultdict(list)

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

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

for key,item in SP:
    item_sort = sorted(item, reverse=True)
    for _,i in item_sort:
        print(i)

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

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

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

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

l = []

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

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

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

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

l = []

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

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

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

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

l = []
ans = []

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

ans = sorted(l, key=lambda x:(x[0],-x[1]))    
for j in ans:
    print(j[2])

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

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

dic = {}
for i in range(n):
    s[i][1] = int(s[i][1])
    s[i].append(i+1)
    restaurant = s[i][0]
    if restaurant not in dic:
        dic[restaurant] = [[s[i][1], s[i][2]]]
    else:
        dic[restaurant].append([s[i][1], s[i][2]])

keys = sorted(dic.keys())

for i in keys:
    for j in range(len(dic[i])):
        value = sorted(dic[i], key=lambda x: x[0], reverse=True)
        print(value[j][1])

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

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

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

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

Solution (Python):
n=int(input())
sp=[list(map(str,input().split()))+[i+1] for i in range(n)]
for i in range(n):
    sp[i][1]=int(sp[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())
List = []
for i in range(n):
    sp = list(map(str, input().split()))
    sp[1] = int(sp[1])
    sp.append(i+1)
    List.append(sp)
List.sort(key=lambda List:(List[0],-List[1]))

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

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

sp.sort()

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

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

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

Solution (Python):
n = int(input())
sr = []
ans = [0]*n
for _ in range(n):
    s,r = input().split()
    sr += [[str(s), int(r)]]
se = sorted(sr, key=lambda x: (x[0], -x[1]))
for i in range(n):
    ans[i] = sr.index(se[i])+1
for i in range(n):
    print(ans[i])

Solution (Python):
r_list = []
ans_list = []
N = int(input())
for i in range(1, N+1):
    Si, Pi = input().split()
    r_list.append((Si, int(Pi), i))
    
name_sorted_list = sorted(r_list, key=lambda x:x[0])

while len(name_sorted_list) > 0:
    test_list = []
    list_index = [i for i, x in enumerate(name_sorted_list) if x[0]  == name_sorted_list[0][0]]
    for i in list_index:
        test_list.append(name_sorted_list[i])
    for i in reversed(list_index):
        del name_sorted_list[i]
    test_list = sorted(test_list, key=lambda x:x[1], reverse = True)
    for item in test_list:
        ans_list.append(item)
    
for item in ans_list:
    print(item[2])

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

a = [list(map(str, input().split())) for _ in range(N)]
lst = []

for i, (x, y) in enumerate(a):
    lst.append([i + 1, x, int(y)])

lst.sort(key=lambda x:(x[1], -x[2]))
for i, x, y in lst:
    print(i)

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

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

lst.sort(key=lambda x:(x[1], -x[2]))
for i, x, y in lst:
    print(i)

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

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

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

for x in a:
    print(x[2]+1)

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

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

for x in a:
    print(x[2]+1)

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

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

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

Solution (Python):
from collections import defaultdict
N = int(input())
dict1 = defaultdict(list)
for i in range(N):
    S,P = map(str,input().split())
    P = int(P)
    dict1[S].append([P,i+1])

dict2 = sorted(dict1.items())
for i,v in dict2:
    v.sort(reverse = True)
    for j in v:
        print(j[1])

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n = ri()
    lr = []
    for i in range(n):
        s, r = rl()
        lr.append((s, -int(r), i+1))
    lr.sort()
    for r in lr:
        print(r[2])



if __name__ == '__main__':
    main()

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

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

sort1=sorted(X, key=lambda x:x[1], reverse=True)
sort2=sorted(sort1, key=lambda x:x[0])

for j in range(N):
    print(X.index(sort2[j])+1)

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

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

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

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


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

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

Solution (Python):
from operator import itemgetter
N = int(input())
SP_1 = [list(input().split()) for i in range(N)]
for i in range(N) :
    SP_1[i][1] = int(SP_1[i][1])
buf = 0
SP_2 = SP_1
SP_1 = sorted(SP_1,key = itemgetter(0))

for i in range(1,N) :
    if SP_1[i][0] != SP_1[i-1][0] :
        
        SP_1[buf:i] = sorted(SP_1[buf:i],key = itemgetter(1),reverse = True)
        buf = i
SP_1[buf:N] = sorted(SP_1[buf:N],key=itemgetter(1),reverse = True)

for i in range(N) :
    for j in range(N) :
        if SP_1[i] == SP_2[j] :
            print(j+1)
            break

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

Solution (Python):
from operator import itemgetter

n = int(input())
r = [['', 0, 0]] * n

for i in range(n):
  s_input, p_input = input().split(' ')
  r[i] = [s_input, int(p_input), i+1]



s = sorted(r, key=itemgetter(1), reverse=True)
sorted_for_book = sorted(s, key=itemgetter(0))

for item in sorted_for_book:
  print(item[2])

Solution (Python):



import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

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

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

for i in range(N):
  x_new.append([i+1, x[i][0], int(x[i][1])])
  
x_new.sort(key=lambda x: x[2], reverse=True)
x_new.sort(key=lambda x: x[1])

for j in x_new:
  print(j[0])

Solution (Python):

import sys
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')

n = int(input())

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

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


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

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

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


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

Solution (Python):
import copy
n=int(input())
alis=[]
for i in range(n):
	a,b=map(str,input().split())
	alis.append([a,int(b)])
blis=copy.copy(alis)
blis.sort(key=lambda blis:(blis[0],-blis[1]))
for i in blis:
	print(alis.index(i)+1)

Solution (Python):

from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time



def I(): return int(input())
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)



show_flg = True


def main():
    N = I()
    restrants = [None] * N

    for i in range(N):
        S, P = MS()
        restrants[i] = (S, int(P), i+1)

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

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


if __name__ == '__main__':
    main()

Solution (Python):

N = int(raw_input())
Restaurant = {}
for i in xrange(N):
    city, score  = raw_input().split()
    if city in Restaurant.keys():
        Restaurant[city].append((int(score), i+1))
    else:
        Restaurant[city] = [(int(score), i+1)]

city_sort = sorted(Restaurant.keys())
for city in city_sort:
    score_sort = sorted(Restaurant[city], key=lambda x:x[0], reverse=True)
    for score in score_sort:
        print score[1]

Solution (Python):
N = int(input())
SPn =[]
for i in range(N):
    SP = input().split(' ')
    S = SP[0]
    P = int(SP[1])
    SPn.append([S,P,i+1])
SPn.sort()
first_val = SPn[0][0]
current_list = [SPn[0]]
for i in range(1,N):
    if first_val == SPn[i][0]:
        current_list.append(SPn[i])
    else:
        current_list.sort(key=lambda x:(x[1]), reverse=True)
        for val in current_list:
            print(val[2])
        current_list = [SPn[i]]
        first_val = SPn[i][0]
current_list.sort(key=lambda x:(x[1]), reverse=True)
for val in current_list:
    print(val[2])

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

for j in x_new:
  print(j[0])

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

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

Solution (Python):
import sys
input = sys.stdin.readline
import numpy as np
def print_ans(N, ar):
    """Test Case
    >>> print_ans(6,[["khabarovsk",-20, 1], ["moscow",-10, 2], ["kazan",-50, 3], ["kazan",-35, 4], ["moscow",-60, 5], ["khabarovsk",-40, 6]])
    3
    4
    6
    1
    5
    2
    >>> print_ans(10, [["yakutsk", -10, 1 ], ["yakutsk", -20, 2 ], ["yakutsk", -30, 3 ], ["yakutsk", -40, 4 ], ["yakutsk", -50, 5 ], ["yakutsk", -60, 6 ], ["yakutsk", -70, 7 ], ["yakutsk", -80, 8 ], ["yakutsk", -90, 9 ], ["yakutsk", -100,10]])
    10
    9
    8
    7
    6
    5
    4
    3
    2
    1
    """
    ans = sorted(ar)
    for a in ans:
        print(a[2])

if __name__ == '__main__':
    N = int(input().rstrip())
    ar = []
    for i in range(N):
        s, p = input().rstrip().split()
        p = int(p)
        ar.append([s, -p, i + 1])
    print_ans(N, ar)

Solution (Python):
n = int(input())
def int_or_st(i):
  if str.isnumeric(i):
    return int(i)
  else:
    return i
res = [list(map(int_or_st,input().split())) for _ in range(n)]
sorted_res = sorted(res,reverse=True,key=lambda x:x[1])
sorted_res.sort(key=lambda x:x[0])
for i in sorted_res:
  print(res.index(i)+1)

Solution (Python):

N = int(input())

order_city_point = []
for i in range(1,N+1):
    city,point = input().split()
    order_city_point.append([i,city,int(point)]) 

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

for order,_,__ in order_city_point:
    print(order)

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

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

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

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

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

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

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

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

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

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

Solution (Python):
N=int(input())
X=[]
for i in range(N):
  S,P =map(str,input().split())
  X +=[[S,100-int(P),i+1]]
X=sorted(X)
for j in range(N):
  print(X[j][2])

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

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

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

items = list(SP.items())
items.sort()
for _, A in items:
    A.sort(reverse=True)
    for _, i in A:
        print(i)

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

data = [["",0,0] for i in range(n)]

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



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

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

Solution (Python):

from operator import itemgetter

n = int(input())

s = []
p = []

for _ in range(n):
    tmp = [s for s in input().split()]
    s.append(tmp[0])
    p.append(int(tmp[1]))

restaurants = []
for i in range(n):
    restaurants.append([i + 1, s[i], p[i]])

restaurants.sort(key=itemgetter(2), reverse=True)
restaurants.sort(key=itemgetter(1))

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

Solution (Python):
N=int(input())
d=[]
if N>0:
  for i in range(N):
    city,score=input().split(" ")
    score=int(score)
    d.append([i+1,city,score])

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

Solution (Python):
n = int(input())
s = [0]*n
p = [0]*n
l = [[] for i in range(n)]

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

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

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

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

book = []

for i in range(n):
    line = input().split()
    name = line[0]
    score = int(line[1])
    number = i+1
    list = [name,score,number]
    book.append(list)


'''
book.sort(key=lambda x: x[n])でソート
-マイナス指定している・・・
'''
book.sort(key=lambda x: (x[0], -x[1]))
print("")
[print(item[2]) for item in book]

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

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

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

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

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

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

Solution (Python):
import unittest


class TestB(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([
                ['khabarovsk' ,20],
                ['moscow', 10],
                ['kazan', 50],
                ['kazan', 35],
                ['moscow', 60],
                ['khabarovsk', 40]
            ]),
                [3, 4, 6, 1, 5, 2]
        )

    def test_2(self):
        self.assertEqual(think([
                ['yakutsk', 10],
                ['yakutsk', 20],
                ['yakutsk', 30],
                ['yakutsk', 40],
                ['yakutsk', 50],
                ['yakutsk', 60],
                ['yakutsk', 70],
                ['yakutsk', 80],
                ['yakutsk', 90],
                ['yakutsk', 100]
            ]),
                [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
        )


def solve():
    list_of_s_and_p = read()
    result = think(list_of_s_and_p)
    write(result)


def read():
    n = read_int(1)[0]
    list_of_s_and_p = []
    for _ in range(n):
        buf = read_line().split()
        list_of_s_and_p.append([buf[0], int(buf[1])])
    return list_of_s_and_p


def read_int(n):
    return read_type(int, n)


def read_float(n):
    return read_type(float, n)


def read_type(t, n):
    return list(map(lambda x: t(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(list_of_s_and_p):
    data_with_index = []
    for i, e in enumerate(list_of_s_and_p):
        data_with_index.append((i + 1, e[0], e[1]))
    data_with_index.sort(key=lambda x: (x[1], -x[2]))
    return [x[0] for x in data_with_index]


def write(result):
    for r in result:
        print(r)


if __name__ == '__main__':
    
    solve()

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

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

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

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

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