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):
from heapq import heappush, heappop


n = int(input())
ans = []
for i in range(1, n + 1):
    s, p = input().split()
    p = int(p)
    heappush(ans, (s, -p, i))
while ans:
    print(heappop(ans)[2])

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

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

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

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

Solution (Python):
n = int(input())
n_list = [0]*n
for i in range(n):
    n_list[i] = input().split()
    n_list[i].append(i+1)
for i in range(n):
    n_list[i][1] = int(n_list[i][1])
n_list.sort()
n_list.append("dum")

L = 0
for i in range(n):
    if n_list[i][0] != n_list[i+1][0]:
        for j in range(i,L-1,-1):
            print(n_list[j][2])
        L = i+1

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

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

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

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

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

Solution (Python):
n=int(input())
keep=[]
re_ans=[]

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

for J in range(n):
    j=keep[J]
    ans=1
    for k in (keep):
        if j[0]>k[0]:
            ans+=1
        elif j[0]==k[0] and int(j[1])<int(k[1]):
            ans+=1
    re_ans.append(ans)
for i in range(n):
    print(re_ans.index(i+1)+1)

Solution (Python):
n=int(input())
sp=[0]*n
for i in range(n):
	s,p=input().split()
	p=str(100-int(p))
	if len(p)==1:
		p="0"+p
	elif len(p)==3:
		p="999"+p
	sp[i]=[s+p,i+1]
sp.sort()
for i in range(n):
	print(sp[i][1])

Solution (Python):
n=int(input())
l=sorted([(s,-int(p),i+1) for i,(s,p) in enumerate([tuple(input().split()) for _ in range(n)])])
a,s,d=zip(*l)
print(*d,sep="\n")

Solution (Python):
n = int(input())
s =  [input().split() for i in range(n)]
temp = s
data = sorted(s,key=lambda x:(x[0],-int(x[1])))


for i in range(n):
    y = data[i]
    result = temp.index(y)
    print(result+1)

Solution (Python):
N = int(input())
W = [list(input().split()) for _ in range(N)]
S = sorted(W)
for i in range(N):
  for j in range(i+1, N):
    if S[i][0] == S[j][0] and int(S[i][1]) < int(S[j][1]):
      a = S[i]
      S[i] = S[j]
      S[j] = a
for k in range(N):
  print(W.index(S[k])+1)

Solution (Python):
n=int(input())
lis=[]
for i in range(0,n):
  p,q=map(str,input().split())
  lis.append([p,int(q),i+1])
for j in range(0,n):
  for k in range(0,n-1):
    if lis[n-k-1][0]<lis[n-k-2][0]:
      t=lis[n-k-2]
      lis[n-k-2]=lis[n-k-1]
      lis[n-k-1]=t
    elif lis[n-k-1][0]==lis[n-k-2][0]:
      if lis[n-k-1][1]>=lis[n-k-2][1]:
        t=lis[n-k-2]
        lis[n-k-2]=lis[n-k-1]
        lis[n-k-1]=t
      
for i in range(n):
  print(lis[i][2])

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

lst = sorted(lst)
for j in range(N):
    print(lst[j][2])

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


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

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

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

ls.sort(key=lambda l:l[2], reverse=True)
ls.sort(key=lambda l:l[1])

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

Solution (Python):
import sys

input = sys.stdin.readline
MOD = 1000000007

N = int(input())

x = {}
c  = {}

res = []

i = 0
for j in range(1,N+1):
    s,p =input().split()
    p = int(p)
    if s not in x:
        x[s]   = i
        i+=1
        res.append([])

    res[x[s]].append(p)
    c[p] = j


for j in range(i):
    res[j].sort()

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

for  key,value in dict2: 

    
    for j in res[value][::-1]:
        print(c[j])

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

Solution (Python):


from copy import copy, deepcopy

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

cities=[]
for s in sp:
    cities.append(s[0])
cities=list(set(cities))
cities.sort()

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

for c in cities:
    for i in range(n):
        if sp[i][0]==c:
            print(sp_.index(sp[i])+1)

Solution (Python):
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd 
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) 

n = int(input())
res = {}
ans = []
for _ in range(n):
    s, p = input().split()
    ans.append(int(p))
    if s in res:
        res[s].append(int(p))
    else:
        res[s] = [int(p)]
stdRes = sorted(res.keys())
for x in stdRes:
    for m in sorted(res[x], reverse=True):
        print(ans.index(m) + 1)

Solution (Python):
n = int(input())
l = [[0]*3 for _ in range(n)]

for i in range(n):
    x, y = input().split()
    l[i][0] = x
    l[i][1] = int(y)*-1
    l[i][2] = i + 1

l.sort()

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

Solution (Python):

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

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

a = []

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

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

Solution (Python):
A = int(input())
l = []
for i in range(A):
    A = input().split()
    B = int(A[1])
    A = A[0]
    l.append([A,B])
l_after = list(l)
l_after.sort(key=lambda x:(x[0],-x[1]))
for i in l_after:
    print(l.index(i)+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])

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

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

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

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

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

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

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

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

Solution (Python):
lst = [input().split()+[str(i+1)] for i in range(int(input()))]
print("\n".join([i[2] for i in sorted(lst, key=lambda x:(x[0], -1*int(x[1])))]))

Solution (Python):
n = int(input())
s = []
c = {}
nums = {}
for i in range(n):
    ipt = input().split()
    nums[int(ipt[1])] = i + 1
    if not ipt[0] in c:
        s.append(ipt[0])
        c[ipt[0]] = [int(ipt[1])]
    else:
        c[ipt[0]].append(int(ipt[1]))

s.sort()

for i in s:
    c[i].sort()
    for j in c[i][::-1]:
        print(nums[j])

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


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

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


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

for info in info_list:
    print(info[2])

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

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

Solution (Python):
import sys
import math
from collections import Counter
import itertools



def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

def LI(): return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'


p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")



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

Solution (Python):
from operator import itemgetter

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

def multisort(target_list, specs):
    for key, reverse in reversed(specs):
        target_list.sort(key=key, reverse=reverse)
    return target_list

temp_list = multisort(temp_list, ((itemgetter(1), False), (itemgetter(2), True)))

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

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

Solution (Python):
from operator import itemgetter

n = int(input())

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

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

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

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

res = sorted(sp)
for i in range(n):
    print(res[i][2]+1)

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
SR = []
for i in range(1,N+1):
    s, r = input().split()
    SR.append((s,-int(r),i))

SR.sort(key=lambda x: (x[0],x[1]))
for ans in SR:
    print(ans[2])

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

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

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

import numpy as np

s_list = []
p_list = []
for i in inp:
    s_list.append(i.split()[0])
    p_list.append(int(i.split()[1]))

sp_list = []
for i in range(N):
    sp_list.append([s_list[i],p_list[i]])


sort_sp_list = sorted(sp_list)


s_type = sorted(list(set(s_list)))
tmp_list = []
for type in s_type:
    tmp_list.append(sorted([s for s in sort_sp_list if s[0] == type],reverse=True))

rank_list = []
for tmp in tmp_list:
    for l in tmp:
        rank_list.append(l)

for rank in rank_list:
    print(sp_list.index(rank)+1)

Solution (Python):
import numpy as np
N=int(input())
S_list=[]
T_point=[]
zisho = "abcdefghijklmnopqrstuvwxyz"
for i in range(N):
  SP = input().split()
  S_list.append(SP[0])
  zisho_num = 0
  for k in range(len(SP[0])):
    zisho_num = zisho_num + (zisho.index(SP[0][len(SP[0])-k-1])+1)*(100**(k+10-len(SP[0])))
  T_point.append(zisho_num*100+100-int(SP[1]))
T_point = np.array(T_point)
ind = T_point.argsort()
for i in range(N):
  print(ind[i]+1)

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

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

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

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

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

for r in sorted(rs):
    print(r[2])

Solution (Python):
import sys

n = int(input())
rs = [ [i+1, input().split()] for i in range(n) ]


rs = sorted(rs, key=lambda a:int(a[1][1]), reverse=True)
rs = sorted(rs, key=lambda a:a[1][0])

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

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

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

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

sp.sort()


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

Solution (Python):


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

for i in range(1, n+1):
    city, point = map(str, input().split())
    r.append(list((i, city, int(point))))

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

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

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

B=sorted(A)
for f in range(n):
    print(B[f][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 x in a:
  print(x[2])

Solution (Python):
N=int(input())
data = [None] * N
for i in range(N):
  data[i] = list(input().split()) + [i+1]
  
data = sorted(data,key=lambda x:(x[0],-int(x[1])))
for d in data:
  print(d[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)

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

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

map_list = [[0,'abc',0] for i in range(n)]

for i in range(n):
    input_line = input().split()
    map_list[i]=[i,input_line[0],int(input_line[1])]

ans_li = sorted(map_list,key=lambda x:(x[1],-x[2]))
for ans in ans_li:
    print(ans[0]+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 a:
    print(i[2])

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
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 [I() 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()
    L=[]
    for i in range(N):
        S,T=ST().split()
        T=int(T)
        L.append((S,T,i))
    L.sort(reverse=True,key=lambda x:x[1])
    L.sort(key=lambda x:x[0])
    print(*[i+1 for x,y,i in L],sep="\n")

if __name__ == '__main__':
    main()

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

guidebook = list()
for num in range(n):
    s = input().split()
    new_page = [s[0], -int(s[1]), int(num + 1)]
    guidebook.append(new_page)
sorted_data = sorted(guidebook, key=lambda x:(x[0], x[1]))

for page in sorted_data:
    print(page[2])

Solution (Python):
n = int(input())
sp = [input().split() for _ in range(n)]
sp_s = sorted(sp, key=lambda x:(x[0], -int(x[1])))
for i in sp_s:
    print(sp.index(i)+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())
A = [[input().split(), i+1] for i in range(N)]

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

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

Solution (Python):
n = int(input())
l = [input().split() for _ in range(n)]
for i in range(n):
    l[i][1] = 100 - int(l[i][1])
m = sorted(l, reverse = True)
for i in range(n):
    for j in range(n):
        if m[n - i - 1] == l[j]:
            print(j + 1)

Solution (Python):
import time
startTimeProblem=time.time()

import fileinput, sys, itertools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()



N = In.int()
arr = []

for i in range(1, N+1):
    line = In.str().split()

    arr.append((i, line[0], int(line[1])))

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

res = [x[0] for x in arr]

Out.intsNL(res)




if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

for i in range(1, N+1):
	SP[i-1].append(i)

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
Rs = []
for i in range(1, N+1):
    Ss, P = input().split()
    Rs.append((Ss, -int(P), i))

Rs.sort()

for _, _, i in Rs:
    print(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(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):
    L = input().split()
    list.append([i+1, L[0], int(L[1])])

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

for k in range(N):
    print(list[k][0])

Solution (Python):

N = int(input())

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

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

for k in [shop[0] for shop in shops]:
    print(k)

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

d = {}
S = set()

for i in range(N):
    s,p = input().split()
    p = int(p)
    S.add(s)
    if s in d:
        d[s].append([p, i+1])
        continue
    d[s] = []
    d[s].append([p, i+1])
S = list(S)
S.sort()

for key in S:
    L = d[key]

    L = sorted(L, reverse=True)
    for l in L:
        print(l[1])

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

for i in range(n):
    s,p = input().split()
    rc.append((str(s),int(p)))

rc = (list(enumerate(rc)))

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

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

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

Solution (Python):
N = int(input())
li =[]
for i in range(N):
    s, n = input().split()
    li.append([s, int(n), i+1])
li2 = sorted(li, key=lambda x: x[1], reverse=True)
li3 = sorted(li2, key=lambda x: x[0])
for i in range(N):
    print(li3[i][2])

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

A = []
for i in range(1,N+1):
  a=list(input().split())
  a.append(str(i))
  A.append(a)

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

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

Solution (Python):
def solve():
    N = int(input())
    S = [0]*N
    for i in range(N):
        S[i] = input().split()
        S[i][1] = int(S[i][1])
    T = sorted(S, key=lambda x:(x[0],-x[1]))
    ans = []
    for t in T:
        ind = S.index(t)
        ans.append(ind+1)
    return ans
print(*solve(),sep='\n')

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

Solution (Python):

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

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

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

Solution (Python):

a = int(input())
d = [list(input().split()) for i in range(a)]
d = [[i,-int(j),x] for x,(i,j) in enumerate(d)]
d.sort()
for i,j,k in d:
    print(k+1)

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

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

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

Solution (Python):


n = int(input())

ls = []

for i in range(n):

    s, p = input().split()

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

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

Solution (Python):
icase=0
if icase==0:
    from operator import itemgetter
    n=int(input())
    sp=[]
    for i in range(n):
        si,p=input().split()
        sp.append([si,int(p),i]) 
    sp.sort(key=itemgetter(1),reverse=True)
    sp.sort(key=itemgetter(0))

    for i in range(n):

        print(sp[i][2]+1)

Solution (Python):
N = int(input())
arr = [[0, 0, 0]] * N

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

ans = sorted(arr, key = lambda a: (a[0], -1 * a[1]))

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

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

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

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

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  A = []
  for i in range(N):
    s, p = input().split()
    p = int(p)
    A.append((s, -p, i+1))
  A.sort()
  for s, p, i in A:
    print(i)
  
if __name__ == '__main__':
  main()

Solution (Python):
N = int(input())  
sps = []
ss = []
for i in range(1, N+1):
    s, p = input().split(' ')
    sps.append([i, s, int(p)])
    if s not in ss:
        ss.append(s)

sps = sorted(sps, key=lambda x: x[2], reverse=True)
ss = sorted(ss)
ret = []
for s in ss:
    t = [tmp for tmp in sps if tmp[1]==s]
    ret.extend(t)

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

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

Solution (Python):
n = int(input())
d = {}
l = []
for i in range(n):
    a, b = input().split()
    if a not in l:
        l.append(a)
        d[a] = set([(int(b), i + 1)])
    else:
        d[a].add((int(b), i + 1))
l.sort()
for i in range(len(l)):
    d[l[i]] = list(d[l[i]])
    d[l[i]].sort(reverse=True)
    for j in range(len(d[l[i]])):
        print(d[l[i]][j][1])

Solution (Python):
import sys
input = sys.stdin.readline
def myAnswer(N:int,guidebook:dict) -> None:
   ans = sorted(guidebook.items())
   for _,ary in ans:
      tmp = sorted(ary.items(),reverse=True)
      for t in tmp:
         print(t[1])
      

def modelAnswer():
   tmp=1
def main():
   N = int(input())
   guidebook = {}
   for n in range(N):
      s,p = map(str,input().split())
      if(s in guidebook.keys()):
         guidebook[s][int(p)]=n+1
      else:
         guidebook[s]={int(p):n+1}
   myAnswer(N,guidebook)


if __name__ == '__main__':
   main()

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

Solution (Python):
N=int(input())
scores=[]
for _ in range(N):
    s,p=input().split()
    scores.append((s.strip(),int(p)))
rank=sorted(scores,key=lambda x:(x[0],-x[1]))
for i in rank:
    print(int(scores.index(i))+1)

Solution (Python):
N=int(input())
scores=[]
for _ in range(N):
    s,p=input().split()
    scores.append((s.strip(),int(p)))
rank=sorted(scores,key=lambda x:(x[0],-x[1]))
for i in rank:
    print(int(scores.index(i))+1)