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-----
6
khabarovsk 20
moscow 10
kazan 50
kazan 35
moscow 60
khabarovsk 40

-----Sample Output-----
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.

Difficulty: introductory

Starter code:

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

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

ssp = sorted(sp, key=lambda x:(x[0],-int(x[1])))
for i in range(n):
    print(ssp[i][2])

import re
n = int(input())
R = []
for i in range(n):
    S, P = input().split()
    R.append((S, int(P),int(i+1)))

Point = []
for j in range(n):
    Point.append(R[j][0])
Point = list(sorted(set(Point)))
Point
SR = sorted(R, key=lambda x:(x[0], -int(x[1])))
for k in range(n):
    print(SR[k][2])
pass

N = int(input())
l = []
for i in range(N):
    s,p = input().split()
    l.append([s,int(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(N):
    print(l[i][2])

n=int(input())

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

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

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

from operator import itemgetter
n=int(input())
SP=[list(map(str,input().split())) for i in range(n)]
for sp in SP:
  sp[1] = -1*int(sp[1])
SPsort = sorted(SP,key=itemgetter(0,1))
for i in range(n):
  print(SP.index(SPsort[i])+1)

N = int(input())

l = []

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

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


N = int(input())

d = []
for i in range(N):
    city, score = input().split()
    d.append({'city':city,'score':int(score),'index':i+1})


sorted_d = sorted(d, key=lambda x:x['city'])

unique_city = []

for i in sorted_d:
    if i['city'] not in unique_city:
        unique_city.append(i['city'])

for city in unique_city:
    pool = [x for x in sorted_d if x['city']==city]
    sorted_pool = sorted(pool, key=lambda x:x['score'], reverse=True)
    for i in sorted_pool:
        print((i['index']))


n = int(input())
a = [list(input().split(" ")) for i in range(n)]
b = []
for i in a:
  b.append([i[0], 1000-int(i[1])])
c = sorted(b)

#print(b, c)
for i in c:
  print(b.index(i)+1)

import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
SPs = [LS() for _ in range(N)]

tmp = 1
for SP in SPs:
    
    SP[1] = int(SP[1])
    SP.append(tmp)
    tmp += 1

SPs = sorted(SPs, key=lambda x:(x[0],-x[1]), reverse=False)

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

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

for i in range(N):
    SP[i].append(i+1)
  
ans = sorted(SP, key=lambda x:(x[0], -int(x[1])))

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

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

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

n = int(input())

s = []

for i in range(n):
	s.append((input()+' '+str(i)).split())

for i in range(n):
	s[i][1] = int(s[i][1])
    
s.sort(key=lambda x:x[1], reverse=True)
s.sort(key=lambda x:x[0])

for i in s:
	print(int(i[2])+1)

n=int(input())
s=[]
for i in range(n):
    tmp=input().split()
    tmp[1]=100-int(tmp[1])
    s.append(tmp+[str(i+1)])
s=sorted(s)

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


N = int(input())
SP = []
idx = 1

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

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

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

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

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


N = int(input())
lst = []
for _ in range(N):
    S, P = input().split()
    lst.append([S, int(P)])
dct = dict(enumerate(lst))
lst2 = sorted(lst)

dct2 = {}
for n in lst2:
    if not n[0] in dct2:
        dct2[n[0]] = []
        dct2[n[0]].append(n[1])
    else:
        dct2[n[0]].append(n[1])

for m in dct2.keys():
    dct2[m] = sorted(dct2[m], reverse=True)
    
lst3 = []
for x in dct2.keys():
    for y in dct2[x]:
        lst3.append([x, y])

for i in lst3:
    for k, v in dct.items():
        if i == v:
            print(k+1)

N = int(input())
Rest = dict()
Parg = [0]*(101)
for i in range(N):
    S, P = map(str,input().split())
    P = int(P)
    if S not in Rest:
        Rest[S] = [P]
    else:
        Rest[S] += [P]
    Parg[P] = i+1 
Restsort = sorted(Rest)
for cit in Restsort:
    box = Rest[cit]
    box.sort(reverse = True)
    for j in box:
        print(Parg[j])

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

d = {}
for i, v in enumerate(s_p):
    s = v[0]
    p = v[1]
    if s not in d.keys():
        d[s] = [(i, p)]
    else:
        d[s] = sorted(d[s] + [(i,p)], key=lambda x: int(x[1]), reverse=True)

for key in sorted(d.keys()):
    for i,j in d[key]:
        print(i+1)

N = int(input())

my_list = []

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

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

from operator import itemgetter 
n = int(input())
point = []
ans = []
for i in range(n):
    a,b = input().split()
    s = [a,int(b),i+1]
    point.append(s)

s_point = sorted(point,key=itemgetter(1),reverse=True)
s_point = sorted(s_point,key=itemgetter(0))
[print(s_point[j][2]) for j in range(n)]

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

c = sorted(c, key=lambda x: (x[1], x[2]))
for i in c:
  print(i[0])

n = int(input())
sp = list([input().split() for i in range(n)])
sp2 =[[i] + sp[i] for i in range(n)]

ans = sorted(sp2, key= lambda x:int(x[2]), reverse=True)

ans2 = sorted(ans, key =lambda x:x[1])
for i in range(n):
  
  print(ans2[i][0] +1)

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

for i in range(n):
    l = list(map(str,input().split()))
    l[1] = int(l[1])
    l2 = [l[1], l[0], i + 1]
    tbl.append(l2)

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


N=int(input())

guide=[]

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

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

for i in range(N):
    print(guide_sorted[i][0]+1)

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

n = int(input())
city = []
l = []
for i in range(n):
  s,p = input().split()
  if s not in city: city.append(s)
  l.append((s, int(p), i+1))
  
city = sorted(set(city))
l = sorted(l, key=lambda x: x[1], reverse=True)
for i in city:
  for j in l:
    if i == j[0]: print(j[2])

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

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

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

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


n = int(input())
a = [input().split() for i in range(n)]
for i in range(n):
    a[i][1] = int(a[i][1])
    a[i].append(i + 1)
a.sort()
for i in range(100):
    for j in range(1,n):
        if a[j][0] == a[j-1][0] and a[j][1] > a[j-1][1]:
            a[j-1],a[j] = a[j],a[j-1]
for i in range(n):
    print(a[i][2])

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

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


def solver():
    N = int(input())
    ans = []
    for i in range(1, N+1):
        s, p = [n for n in input().split()]
        ans.append({'id': i, 'city': s , 'point': int(p)})
    ans_s = sorted(ans, key=lambda x: (x['city'], -x['point']))
    for j in ans_s:
        print((j['id']))

def __starting_point():
    solver()

__starting_point()

n = int(input())

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

N = int(input())
book = []
for i in range(N):
    city, sco = input().split()
    sco = int(sco)
    book.append({'city':city, 'score':sco, 'number':i+1})

book.sort(key = lambda x: (x['city'],-x['score']))

for j in range(N):
    print((book[j]['number']))


#import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

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

tmp = 1
for SP in SPs:
    
    SP[1] = int(SP[1])
    SP.append(tmp)
    tmp += 1

SPs = sorted(SPs, key=lambda x:(x[0],-x[1]), reverse=False)

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

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

for info in book:
  print(info[1])

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

for i in range(n) :
    sp[i][1] = int(sp[i][1])
    sp[i].append(i+1)

sp.sort()

for i in range(100):
    for j in range(1,n) :
        if sp[j][0] == sp[j-1][0] :
            if sp[j][1] > sp[j-1][1] :
                sp[j-1],sp[j] = sp[j],sp[j-1]

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


n = int(input())
sp = [list(map(str,input().split())) for i in range(n)]
for i in range(1,n+1):
  sp[i-1][1] = int(sp[i-1][1])
  sp[i-1].append(i)
from operator import itemgetter
sp.sort(key = itemgetter(1),reverse = True)
sp.sort(key = itemgetter(0))
for i in range(n):
  print(sp[i][2])

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


n = int(input())

rest = []

for x in range(n):
  a,b = input().split()
  b = int(b)
  rest.append([a,b])
  
  
rest2 = list(sorted(rest, key=lambda x:(x[1]), reverse=True))
rest3 = list(sorted(rest2,key=lambda x:x[0]))

for i in rest3:
  print((rest.index(i)+1))


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

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

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

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

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

n=int(input())
sp=[list(input().split()) for _ in range(n)]
for i in sp:
    i[1]=100-int(i[1])
for i in range(n):
    sp[i].append(i+1)
sp.sort()
for i in sp:
    print((i[2]))


N = int(input())
restaurants = []
for i in range(N):
    name, rating = input().split()
    restaurants.append([name, -int(rating), i])
restaurants.sort()
for i in restaurants:
    print((i[2] + 1))


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

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

for ans in sort_SP:
    print((ans[0]))



from  operator import itemgetter
N = int(input())
l = []
s = []
for i in range(1, N+1):
  k, v = input().split()
  l.append([k, int(v), i])
  s.append(k)
l = sorted(l)
s = sorted(list(set(s)))

for t in s:
  for n in range(N-1, -1, -1):
    k, v, i = l[n]
    if t == k:
      print(i)



url = "https://atcoder.jp//contests/abc128/tasks/abc128_b"

def main():
    n = int(input())
    town = {}
    rate = []
    for i in range(n):
        t = list(input().split())
        town.setdefault(t[0], {})
        town[t[0]][i+1] = int(t[1])
    town = sorted(list(town.items()), key=lambda x:x[0])
    for k in town:
        sort_town = sorted(list(k[1].items()), key=lambda x:x[1], reverse=True)
        for v in sort_town:
            print((v[0]))


def __starting_point():
    main()

__starting_point()

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

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

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

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

from operator import itemgetter

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

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

restaurants = sorted(restaurants, key=itemgetter(1, 2))

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

N = int(input())
city = []
score = dict()
arr = []
for i in range(N):
  c, s = input().split()
  arr.append([c, int(s)])
  city.append(c)
  if c in score:
    score[c].append(int(s))
  else:
    score[c] = [int(s)]
city.sort()
ans = []
for i, var in enumerate(city):
  t = score[var].index(max(score[var]))
  u = score[var].pop(t)
  ans.append(arr.index([var,u]) + 1)
for i in ans:
  print(i)

N=int(input())
SP=sorted([list(input().split())+[_+1] for _ in range(N)])
tempcity=SP[0][0]
ans=[]
tempans=[]
for i in range(N):
	#print(tempans)
	if tempcity == SP[i][0]:
		tempans.append([int(SP[i][1]),SP[i][2]])
	else:
		tempans=sorted(tempans, reverse=True)
		for h in range(len(tempans)):
			ans.append(tempans[h][1])
		tempans=[]
		tempcity=SP[i][0]
		tempans.append([int(SP[i][1]),SP[i][2]])
	if i==N-1:
		tempans=sorted(tempans, reverse=True)
		for h in range(len(tempans)):
			ans.append(tempans[h][1])
		
for g in range(N):print(ans[g])

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

N = int(input())
S = []
P = []
for i in range(N):
    s,p = input().split()
    S.append(s)
    P.append(int(p))
Sset = sorted(list(set(S)))

dict1 = {}
for i in range(N):
    dict1[P[i]] = S[i]

for k in Sset:
    U = [i for i, j in dict1.items() if j == k]
    V = sorted(U,reverse=True)
    for l in V:
        print(P.index(l) + 1)

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

l = sorted(sp, key=lambda x: (x[1], -x[2]))
for a, b, c in l:
    print(a)

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

for c,p,i in sorted(l):
  print(i)

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

# 地名に関して辞書順に / (-点数)に関して昇順に（点数に関して降順に）並べる
l = sorted(l, key=lambda x:(x[0], x[1]))
for i in range(N):
  print(l[i][2])

n = int(input())
data = [input().split() for i in range(n)]
for i in range(n):
    data[i].append(i + 1)
    if 10 <=int(data[i][1]) < 100:
        data[i][1] = '0' + str(data[i][1])
    elif int(data[i][1]) < 10:
        data[i][1] = '00' + str(data[i][1])
data.sort(key = lambda x :x[1],reverse = True)
data.sort(key = lambda x :x[0])
for i in range(n):
    print(data[i][2])

from typing import List, Tuple


def answer(n: int, sps: List[Tuple[str, int]]) -> List[int]:
    result = []
    numbered_sps = []
    for i, sp in enumerate(sps, start=1):
        s, p = sp
        numbered_sps.append([i, s, p])
    numbered_sps = sorted(numbered_sps, key=lambda x: (x[1], -x[2]))
    for i in numbered_sps:
        result.append(i[0])

    return result


def main():
    n = int(input())
    temp = (input().split() for _ in range(n))
    sps = []
    for s, p in temp:
        sps.append((s, int(p)))
    for i in answer(n, sps):
        print(i)


def __starting_point():
    main()

__starting_point()

N=int(input())
d=[input().split() for i in range(N)]
name=[]
for i in range(N):
    d[i].append(i+1)
    d[i][1]=int(d[i][1])
    name.append(d[i][0])
Name=list(set(name))
Name.sort()
d.sort()
for i in range(len(Name)):
    li=[]
    for j in range(N):
        if Name[i]==d[j][0]:
            li.append([d[j][1],d[j][2]])
        else:
            continue
    li.sort()
    Li=li[::-1]
    for k in range(len(li)):
        print(Li[k][1])

n=int(input())

s_list=[]

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

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



def mapt(fn, *args):
    return list(map(fn, *args))


def Atom(segment):
    try:
        return int(segment)
    except ValueError:
        try:
            float(segment)
        except ValueError:
            return segment


def Input():
    return mapt(int, input().split(" "))


def main():
    n = int(input())
    data = [mapt(Atom, input().split(" ")) for _ in range(n)]
    for i in range(n):
        data[i].append(i)
    data = sorted(data, key=lambda x:x[1], reverse=True)
    data = sorted(data, key = lambda x:x[0])
    for row in data:
        print(row[2]+1)

main()

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

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

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


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


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


import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    restaurants = []
    for _ in range(N):
        s, p = input().split()
        restaurants.append((s.strip(), int(p)))

    rank = sorted(restaurants, key=lambda x: (x[0], -x[1]))
    for a in rank:
        print(int(restaurants.index(a)) + 1)

def __starting_point():
    main()
__starting_point()

l=int(input())
L=[]
for i in range(l):
    n,k=map(str,input().split())
    c=[]
    c.append(n)
    c.append(100-int(k))
    c.append(i+1)
    L.append(c)
L.sort()
for i in range(l):
    print(L[i][2])

n = int(input())
list_res = []
for i in range(0, n):
    s, p = input().split()
    list_res.append([s, int(p), i + 1])
list_res_point = sorted(list_res, key=lambda x: (x[1]), reverse=True)
list_ans = sorted(list_res_point, key=lambda x: (x[0]))
for i in range(0, n):
    print(list_ans[i][2])

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

N = int(input())
R = [input().split() for i in range(N)]

R2 = [{'i':i+1, 's':R[i][0], 'p':int(R[i][1])} for i in range(N)] 

S = []
for r in R:
  if r[0] not in S:
    S.append(r[0])
S.sort()

for s in S:
  rs = [r for r in R2 if r['s'] == s]
  sorted_rs = sorted(rs, key=lambda x:x['p'], reverse=True)
  for r in sorted_rs:
    print(r['i'])

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


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

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

resta_new = sorted(restaurant, key=lambda x:(x[0][0], -int(x[0][1])))
#print(resta_new)

for j in range(N):
    print((resta_new[j][1]))


n=int(input())
dic1={}
bokk=[]
list0=[]
for i in range(n):
  c,p=map(str,input().split())
  p=int(p)
  list0.append([c,p])
  if c not in dic1:
    dic1[c]=[]
  dic1[c].append(p)
dic1=dict(sorted(dic1.items()))
for i,k in dic1.items():
  k.sort(reverse=True)
  for j in k:
    bokk.append([i,j])
for i in bokk:
  print(list0.index(i)+1)

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

# 地名に関して辞書順に / 点数に関して降順に並べる
l = sorted(l, key=lambda x:(x[0], -x[1]))
for i in range(N):
  print(l[i][2])

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

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

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

p.sort()
p.reverse()
tbl2 = []
for i in range(n):
    for j in range(n):
        if(tbl[j][0] == p[i]):
            tbl2.append(tbl[j])
s = list(set(s))
s.sort()
for i in range(len(s)):
    for j in range(len(tbl2)):
        if (tbl2[j][1] == s[i]):
            print((tbl2[j][2]))


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

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


#import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
SPs = [LS() for _ in range(N)]

tmp = 1
for SP in SPs:
    
    SP[1] = int(SP[1])
    SP.append(tmp)
    tmp += 1

SPs = sorted(SPs, key=lambda x:(x[0],-x[1]), reverse=False)

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

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

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

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

n=int(input())
l=[input().split() for i in range(n)]
l2=[x for x in range(n)]
base=list(zip(l2,l))
ans=sorted(base, key=lambda x: int(x[1][1]),reverse=True)
ans=sorted(ans,key=lambda x: x[1][0])

for i in range(n):
    print(1+ans[i][0])

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

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

for i in range(n):
    print(s.index(q[i])+1)

N = int(input())
l = []
for i in range(N):
  s, p = input().split()
  l.append([s, int(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(N):
  print(l[i][2])

#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    restaurants=[]
    n = int(input())
    restaurants=[list(input().split()) for _ in range(n)]

    for idx,restaurant in enumerate(restaurants):
        restaurants[idx][1]=int(str(restaurant[1]))
        restaurants[idx].append(idx+1)
    restaurants.sort(key=lambda x:x[1],reverse=True)
    restaurants.sort(key=lambda x:x[0].lower())
    for restaurant in restaurants:
        print(restaurant[2])

def __starting_point():
    main()
__starting_point()

n = int(input())
L = []
for i in range(n):
  c = []
  a, b = map(str, input().split())
  c.append(a)
  c.append(100-int(b))
  c.append(i+1)
  L.append(c)
L.sort()
for j in range(n):
  print(L[j][2])

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

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

n=int(input())
sp = [input().split() for _ in range(n)]
orde=sorted(sp,key=lambda sp:(sp[0],-int(sp[1])))
for i in orde:
	print(sp.index(i)+1)

N = int(input())
S = [list(input().split()) for _ in range(N)]
for i in S:
    i[1] = 100 - int(i[1])
for i in range(N):
    S[i] += i+1,
S.sort()
for i in S:
    print(i[2])

#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [0] * N
    P = [0] * N
    R = [0] * N
    for i in range(N):
        S[i] , P[i] = list(map(str, input().split()))
    for i in range(N):
        R[i] = i + 1
    for i in range(N):
        P[i] = int(P[i]) * -1


    Z = list(zip(S, P, R))
    Z = sorted(Z)
    S, P, R = list(zip(*Z))

    for i in R:
        print(i)

def __starting_point():
    main()

__starting_point()

n = int(input())
restaurants = []
for i in range(n):
    s, p = input().split()
    restaurants.append((s, int(p)))
sorted_list = sorted(restaurants, key=lambda x:x[1], reverse=True)
sorted_list.sort(key=lambda x:x[0])

for i in range(n):
    print(restaurants.index(sorted_list[i]) + 1)

n = int(input())
rest = [list([*input().split(),i+1]) for i in range(n)]
rest = list(sorted(rest, key = lambda x : (x[0],100 - int(x[1]))))
for i in rest:
    print(i[2])

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

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

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

for i,(c,p) in l:
  print(i+1)

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

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

for i in new_guidebook:
    print((guidebook.index(i)+1))


n = int(input())

restaurant = []

for i in range(n):
    score_list = input().split()
    score_list.append(i+1)
    score_list[1] = int(score_list[1])
    restaurant.append(score_list)

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


url = "https://atcoder.jp//contests/abc128/tasks/abc128_b"

def main():
    n = int(input())
    town = {}
    for i in range(n):
        t = list(input().split())
        town.setdefault(t[0], {})
        town[t[0]][i+1] = int(t[1])
    town = sorted(list(town.items()), key=lambda x:x[0])
    for k in town:
        sort_town = sorted(list(k[1].items()), key=lambda x:x[1], reverse=True)
        for v in sort_town:
            print((v[0]))


def __starting_point():
    main()

__starting_point()