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

s_list = []
cnt = 0
for j in range(n):
    i,p = input().split()
    s_list.append([i,int(p),j])

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

Solution (Python):
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7



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

Solution (Python):
N = int(input())
S = []
cnt = 0
for _ in range(N):
    cnt += 1
    i,p = input().split()
    S.append([i,int(p),cnt])

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

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

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

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

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

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

for i in range(N):
    for j in range(N):
        if S[j][0]==S_sort[i][0] and S[j][1]==S_sort[i][1]:
            print(j+1)

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

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

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

l.sort(key = lambda x: (x[0], -x[1]))
for i in l:
    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())
li = []
for i in range(n):
    s, p = input().split()
    li.append([int(p), s, i+1])

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

for j in range(len(li)):
    print(li[j][2])

Solution (Python):












n = int(input())

dic = {}
for i in range(1,n+1):
    dic[i] = list(input().split())
    dic[i][1] = int(dic[i][1])


ans = sorted(dic.items(),key=lambda x:(x[1][0],-x[1][1]))


for i in range(len(ans)):
    print(ans[i][0])

Solution (Python):
from operator import itemgetter
n = int(input())
sp = []
for i in range(n):
         s,p = input().split()
         tmp = [s,100-int(p),i]
         sp.append(tmp)
sp = sorted(sp,key = itemgetter(0,1))
for i in range(n):
         print(sp[i][2]+1)

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

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

Solution (Python):
from operator import itemgetter

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

def solve():
    N = int(input())
    l = []
    c = 1
    for _ in range(N):
        a, b = list(input().split())
        l.append((a,int(b), c))
        c += 1
    l = multisort(l, [(0, False), (1, True)])
    for (_,_,c) in l:
        print(c)
    



solve()

Solution (Python):
n=int(input())
D={}
for i in range(n):
    s,p=input().split()
    p=int(p)
    if s in D:
        D[s].append([i+1,p])
    else:
        D[s]=[[i+1,p]]
S=sorted(D)
for s in S:
    d=D[s]
    P={}
    for i in d:
        P[i[1]]=i[0]
    p=reversed(sorted(P))
    for q in p:
        print(P[q])

Solution (Python):
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

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

Solution (Python):

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

tmp = []
city = [''] * n
for i in range(n):
    tmp.append([sp[i][0], 100 - int(sp[i][1]), i+1])
    city[i] = sp[i][0]

tmp.sort()

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n = INT()
sp = [S_LIST() for _ in range(n)]
for i in range(n):
    sp[i][1] = float(1 / (int(sp[i][1]) + 1))
    sp[i].append(i + 1)
sp.sort()
for i in range(n):
    print(sp[i][2])

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

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

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
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

a = []
b = []
for i in range(N):
	if S[i][0] not in a:
		a.append(S[i][0])
		b.append([[i + 1, int(S[i][1])]])
	else:
		for j in range(len(a)):
			if S[i][0] == a[j]:
				b[j].append([i + 1, int(S[i][1])])

index = sorted(range(len(a)), key=lambda x: a[x])


for i in range(len(index)):
	li = sorted(b[index[i]], key = lambda x: (x[1], x[0]), reverse = True)
	for j in range(len(li)):
		print(li[j][0])

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
sp=[]
for i in range(n):
	s,p=input().split()
	sp.append([s,int(p),i+1])

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

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())
sp=[]
for i in range(n):
	s,p=input().split()
	sp.append([s,int(p),i+1])

sp.sort(key=lambda c:(c[0],-c[1]))
for i in sp:
	print(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 c:(c[0],-c[1]))
for i in sp:
	print(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 c:(c[0],-c[1]))
for i in sp:
	print(i[2])

Solution (Python):
N=int(input())
S=[];P=[];Q=[];X=[]
for i in range(N):
  s,p=map(str,input().split())
  S.append(s)
  P.append(int(p))
  Q.append(i+1)
T=list(map(list,zip(Q,S,P)))
T.sort(reverse=True,key=lambda x: x[2])
O=sorted(set(S))

for i in range(len(O)):
  for j in range(len(T)):
    
    if T[j][1]==O[i]:
      X.append(T[j][0])
for i in X:
  print(i)

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

res = []
qes = []
score = []
for i in xrange(n):
    r,s = raw_input().split()
    if r not in d:
        d[r] = [(int(s),i)]
    else:
        d[r].append((int(s),i))
    if r not in res:
        qes.append(r)
    res.append(r)
    score.append(s)
qes = sorted(qes)

for j in qes:
    for k in sorted(d[j],reverse=True):
        print  k[1]+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()
for ans in sp:
  print(ans[-1])

Solution (Python):
n = int(input())
l = []
d = {}
for i in range(n):
    s, p = input().split()
    p = int(p)
    if s in d:
        d[s].append([p, i])
    else:
        d[s] = [[p, i]]
l = sorted(d.keys())
for i in l:
    d[i] = sorted(d[i])
    while len(d[i]) != 0:
        print(d[i].pop()[1] + 1)

Solution (Python):
import numpy as np
N = int(input())
city_num = {}
score = []

for i in range(N):
    s, p = input().split()
    if s not in city_num.keys():
        city_num[s] = [i]
    else:
        city_num[s].append(i)
    score.append(int(p))
    
score_rank = np.argsort(score)[::-1]  
city_num = sorted(city_num.items())

for city, num in city_num:
    order = [s for s in score_rank if s in num]
    [print(o + 1) for o in order]

Solution (Python):
from operator import itemgetter
n = int(input())

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

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

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

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

guidebook = {}

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

for city in sorted(guidebook.keys()):
    data = sorted(guidebook[city])
    for d in data[::-1]:
        print(d[1])

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

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

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

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

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

Solution (Python):
n = int(input())
t = []
for _ in range(n):
  t.append(list(input().split()))
print(*[p+1 for p, _ in sorted(enumerate(t), key = lambda x: (x[1][0], -int(x[1][1])))], sep="\n")

Solution (Python):
n = int(input())
t = []
for _ in range(n):
  t.append(list(input().split()))
print(*[p+1 for p, _ in sorted([[i, j] for i, j in enumerate(t)], \
key = lambda x: (x[1][0], -int(x[1][1])))], sep="\n")

Solution (Python):
n = int(input())
res = []
sco = []
idx = []

for i in range(n):
    _list = list(input().split())
    _list.append(i+1)
    res.append(_list)

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

for i, j, k in res:
    print(k)

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

Solution (Python):
N = int(input())
res = []
for i in range(N):
    name,price = input().split()
    index = i+1
    res.append([index,name,int(price)])

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

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

Solution (Python):
N = int(input())
lst = [[] for _ in range(N)]

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

Solution (Python):
n = int(input())
dic = {}
for i in range(n):
    dic[tuple(list(input().split()))] = i
lst = list(dic.keys())
lst.sort(key = lambda x:(x[0],-int(x[1])))
for i in range(n):
    print(dic[lst[i]]+1)

Solution (Python):
from operator import attrgetter
class Guide(object):
    def __init__(self,no,name,val):
        self.no=no+1
        self.name=name
        self.val=val

n=int(input())
l=[]
for i in range(n):
    name,val=list(input().split())
    val=int(val)
    l.append(Guide(i,name,val))

l.sort(key=attrgetter('val'),reverse=True)
l.sort(key=attrgetter('name'))

for h in l:
    print(h.no)

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

for i in range(n):
  s_p.append(input().split())
  s_p[i].append(i + 1)

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

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

Solution (Python):
N = int(input())
city = dict()
restaurants = []
for _ in range(N):
    s, p = input().split()
    restaurants.append([s, int(p)])
    if s in city.keys():
        city[s].append(int(p))
    else:
        city[s] = [int(p)]

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

for c in city:
    points = c[1]
    points.sort(reverse=True)
    for p in points:
        for i in range(N):
            s = c[0]
            r = restaurants[i]
            if r[0] == s and r[1] == p:
                print(i + 1)

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

for i in range(1,N+1):
    S,P = input().split(" ")
    if S in Dict:
        Dict[S].append((int(P),i))
    else:
        Dict[S] = [(int(P),i)]
        
for j in sorted(Dict):
    l = sorted(Dict[j],reverse=True)
    for k in range(len(l)):
        print(l[k][1])

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

for i in range(n):
    s_p_list.append(input().split())
    s_p_list[i].append(i+1)

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

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

Solution (Python):
def main():
    N = int(input())
    SP = []
    for i in range(N):
        line = input().split()
        SP.append([i + 1, line[0], int(line[1])])
    SP = sorted(SP, key=lambda x: (x[1], -x[2]))
    for i in SP:
        print(i[0])


if __name__ == '__main__':
    main()

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

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

sp.sort()
shop = sp[0][0]
sameshop = [sp[0][2]]
ten = []

for i in range(1,n):
    if sp[i][0] == shop:
        sameshop.append(sp[i][2])
    else:
        ten = ten+sameshop[::-1]
        sameshop = []
        sameshop.append(sp[i][2])
        shop = sp[i][0]

ten = ten+sameshop[::-1]

for i in ten:
    print(i)

Solution (Python):
n = int(input())
key = []
for i in range(n):
  flag = True
  s, p = map(str, input().split())
  for j in range(len(key)):
    if key[j][0] == s:
      key[j][1].append([int(p), i+1])
      flag = False
      break
  if flag:
    key.append([s, [[int(p), i+1]]])
key.sort()
for i in range(len(key)):
  key[i][1].sort(reverse=True)
  for j in range(len(key[i][1])):
    print(key[i][1][j][1])

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


for i,x,z in l:
    print(z)

Solution (Python):
a = range(1, int(input())+1)
b = sorted(a, key=lambda _:[(s, -int(p)) for s, p in[input().split()]])
print(*b)

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

town = set()
for i in sp:
    town.add(i[0])

d = {}
for i in town:
    d[i] = []

for i in sp:
    d[i[0]].append([int(i[1]), i[2]])

town = sorted(list(town))

for i in town:
    tmp = d[i]
    tmp.sort(reverse=True)
    for j in tmp:
        print(j[1])

Solution (Python):
from operator import itemgetter
N = int(input())
S = []
P = []
Num = []
for _ in range(N):
    S1, P1 = [_ for _ in input().split()]
    Num.append(_)
    S.append(S1)
    P.append(P1)
P = [int(_) for _ in P]

c = zip(Num, S, P)
c = sorted(c, key=itemgetter(2), reverse=True)
c = sorted(c, key=itemgetter(1))
Num, S2, P2 = zip(*c)
for i in Num:
    print(i+1)

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

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

for s in sorted(list(rests)):
  rest = rests[s]
  rest.sort(key = lambda x:x[1], reverse = True)
  for i,p in rest:
    print(i)

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

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

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

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

N = int(input())

res = []

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

res.sort()

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

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


for i,x,z in l:
    print(z)

Solution (Python):
n = int(input())
g = {}
cnt = 0
for i in range(n):
    cnt += 1
    l,p = map(str,input().split())
    if l in g:
        g[l].append([p,cnt])
    else:
        g[l] = [[p,cnt],]

for i in g:
    g[i].sort(key = lambda x:int(x[0]) ,reverse = True)
    
g = sorted(g.items())

for j in g:
    for k in j[1]:
        print(k[1])

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

for spi in g:
    spi[1] = int(spi[1])

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


for spi in g:
    print(spi[2])

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

Solution (Python):
n=int(input())
l1=[]
l2=[]
for i in range(n):
    sp=input().rstrip().split()
    l1.append(sp[0])
    l2.append(-int(sp[1]))
l=list(zip(l1,l2))

ans=sorted(l)

for i in range(len(ans)):
    print(l.index(ans[i])+1)

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

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

for i in range(N):
    for j in reversed(range(i+1,N)):
        if SP[i][0] > SP[j][0]:
            SP[i],SP[j] = SP[j],SP[i]
        elif SP[i][0] == SP[j][0] and SP[i][1] < SP[j][1]:
            SP[i],SP[j] = SP[j],SP[i]

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

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    g = []
    for i in range(n):
        s,p = input().split()
        p = int(p)
        g.append((s,-p,i+1))
    g.sort()
    for a,b,i in g:
        print(i)
    return


if __name__ == "__main__":
    solve()

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

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



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

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

Solution (Python):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
SP = [sr().split() + [i+1] for i in range(N)]
SP.sort(key = lambda x: (x[0], -int(x[1])))
for x in SP:
    print(x[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 x: x[1], reverse=True)
SP.sort(key=lambda x: x[0])
for sp in SP: print(sp[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()

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

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

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

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

city=sorted(a)   

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

Solution (Python):

n = int(input())
sp = []
for _ in range(n):
  s, i = input().split()
  sp.append([s, int(i)])
ans = sorted(range(1, n+1), key=lambda x: sp[x-1][1], reverse=True)
ans.sort(key=lambda x: sp[x-1][0])
print(*ans, sep='\n')

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

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

Solution (Python):


n = int(input())
l = []
for i in range(n):
    ss, pp = map(str, input().split())
    l.append([ss, int(pp), i])
    
l.sort(key=lambda x: x[1], reverse=True)
l.sort(key=lambda x: x[0])

for v in l:
    print(v[2]+1)

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

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



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

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

Solution (Python):
from operator import itemgetter
N = int(input())

SP = [["", "", i+1] for i in range(N)]
kari = []

for i in range(N):
  kari.append(list(map(str, input().split())))
  
for i in range(N):
  SP[i][0] = kari[i][0]
  SP[i][1] = int(kari[i][1])

SP.sort(key=itemgetter(1), reverse=True)
SP.sort(key=itemgetter(0))

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

Solution (Python):
n = int(input())
s = [0] * n
p = [0] * n

dic = {}
for i in range(n):
    tmp = input().split()
    s[i], p[i] = str(tmp[0]), int(tmp[1])

arr = sorted(s)
arr = list(set(arr))
arr.sort()

for i in range(len(arr)):
    x = []
    for j in range(n):
        if arr[i] == s[j]:
            x.append(p[j])
    x.sort()
    x.reverse()
    for j in range(len(x)):
        for k in range(n):
            if arr[i] == s[k] and x[j] == p[k]:
                print(k+1)

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

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

city=sorted(a)   

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

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

Solution (Python):
n = int(input())
S = []
P = []
for i in range(n):
    tmp_S, tmp_P = input().split()
    S.append(tmp_S)
    P.append(int(tmp_P) * -1)
index = [i for i in range(1, n+1)]

ZIP = zip(S, P, index)
ZIP = sorted(ZIP)
S, P, index = zip(*ZIP)

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

Solution (Python):
N = int(input())
S = []
P = []
for i in range(N):
    tmp_S, tmp_P = input().split()
    S.append(tmp_S)
    P.append(int(tmp_P)*(-1))

index = [i for i in range(1,N+1)]

ZIP = zip(S, P, index)

ZIP = sorted(ZIP)

S, P, index = zip(*ZIP)

for i in range(N):
    print(index[i])

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
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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

SPi = [(i+1, (S, P)) for i, (S, P) in enumerate(SP)]
SPi.sort(key=lambda x:(x[1][0], -x[1][1]))
print(*[x[0] for x in SPi], sep="\n")

Solution (Python):
N = int(input())
SP = [["", 0, 0] for _ in range(N)]
for i in range(N):
  line = [el for el in input().strip().split()]
  SP[i][0], SP[i][1] = line[0], int(line[1])
  SP[i][2] = 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 sys import stdin

n = int(stdin.readline().rstrip())
g = []

for i in range(n):
    line = stdin.readline().rstrip().split()
    g.append([i+1, line[0], line[1].zfill(3)])

gg = [tuple(i) for i in g]

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

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

Solution (Python):
N = int(input())
S = [[0]*3 for i in range(N)] 

for i in range(N):
   a,b = input().split()
   S[i][0] = a
   S[i][1] = int(b)*(-1)
   S[i][2] = i+1

S.sort()

l = []
for i in range(N):
   l.append(str(S[i][2]))

ans = "\n".join(l)
print(ans)

Solution (Python):

import sys


def solve(N: int, S: "List[str]", P: "List[int]"):
    cityDict = {}
    cityNameSet = set()
    for i in range(N):
        city = S[i]
        point = P[i]
        cityNameSet.add(city)
        if city not in cityDict:
            cityDict[city] = []
        cityDict[city].append((point,i))
    for city in sorted(list(cityNameSet)):
        arr = cityDict[city]
        arr.sort(reverse=True)
        for a in arr:
            print(a[1]+1)
    return



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

if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
d = {tuple(map(str, input().split())):i for i in range(1,n+1)}
sort_d = sorted(d.items(), key=lambda x:(x[0][0],-int(x[0][1]))) 
r = []
for i in sort_d:
  print(i[1])

Solution (Python):


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

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


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

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

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

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

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

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

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

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

a = {}
b = []
for i in range(n):
  s, p = input().split()
  p = int(p)
  
  b.append(s)
  
  if s in a:
    a[s].append([p, i+1])
  else:
    a[s] = [[p, i+1]]
    
b = sorted(list(set(b)))

for i in b:
  tmp = a[i]
  for j in sorted(tmp, reverse = True):
    print(j[1])

Solution (Python):
N = int(input())
restaurant = [tuple(input().split()) + (idx + 1,) for idx in range(N)]

restaurant.sort(key=lambda x: (x[0], -1 * int(x[1])))
for r in restaurant:
    print(r[2])

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


guide.sort()

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

Solution (Python):

n = int(input())

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


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

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


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

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

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

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