AtCoder Beginner Contest 128 - Guidebook

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: EASY

Starter code:

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


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])))
for j in range(N):
	print(resta_new[j][1])


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


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


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)


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


N = int(input())
arr = [(0, 0, 0)] * N
for i in range(N):
	(S, P) = input().split()
	arr[i] = (S, -int(P), i + 1)
arr.sort()
for (_, _, i) in arr:
	print(i)


N = int(input())
S = sorted((list((lambda y: (y[0], -int(y[1]), x))(input().split())) for x in range(1, N + 1)))
for x in S:
	print(x[2])


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)


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)


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


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 a_ in a:
	print(a_[2])


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())
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())
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())
SP = [[i] + input().split() for i in range(N)]
SP.sort(key=lambda x: (x[1], -int(x[2])))
for (i, s, p) in SP:
	print(i + 1)


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


[print(x[2]) for x in sorted([(s[0], -int(s[1]), i + 1) for (i, s) in enumerate([input().split() for _ in range(int(input()))])])]


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


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


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())
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 = []
for i in range(n):
	(s, p) = input().split()
	R.append([s, 100 - int(p), i + 1])
R.sort()
for r in R:
	print(r[2])


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


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


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)


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


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


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())
SP = sorted([list(input().split()) + [_ + 1] for _ in range(N)])
tempcity = SP[0][0]
ans = []
tempans = []
for i in range(N):
	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])


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


print('\n'.join(map(str, (x[2] + 1 for x in sorted(((s, -int(p), i) for (i, (s, p)) in enumerate(zip(*[iter(open(0).read().split()[1:])] * 2))))))))


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)


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


N = int(input())
A = []
for _ in range(N):
	(s, n) = input().strip().split(' ')
	n = int(n)
	A += [(s, -n, _ + 1)]
A = sorted(A)
for X in A:
	print(X[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())
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())
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())
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())
L = []
for i in range(N):
	(S, P) = input().split()
	L.append([S, -int(P), i + 1])
for l in sorted(L):
	print(l[2])


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'])


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


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


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


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


n = int(input())
A = []
for i in range(n):
	(a, b) = input().split()
	A.append([a, -int(b), i + 1])
A.sort()
for (s, t, i) in A:
	print(i)


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


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)


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


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


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


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


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


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


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


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, *l) = open(0).read().split()
print(*sorted(range(1, int(n) + 1), key=lambda i: (l[~-i * 2], -int(l[~-i * 2 + 1]))))


N = int(input())
P = [input().split() + [i + 1] for i in range(N)]
P.sort(key=lambda x: (x[0], -int(x[1]), x[2]))
for (_, _, i) in P:
	print(i)


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


(_, *l) = open(0).read().split()
print(*sorted(range(1, len(l) // 2 + 1), key=lambda i: (l[~-i * 2], -int(l[~-i * 2 + 1]))))


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


n = int(input())
t = []
for i in range(n):
	(x, y) = input().split()
	b = [x, -int(y), i + 1]
	t.append(b)
t.sort()
for a in t:
	print(a[2])


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


n = int(input())
l = []
for i in range(n):
	(a, b) = input().split()
	l.append((a, -int(b), i + 1))
l.sort()
for e in l:
	print(e[2])


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


N = int(input())
P = [0] * N
for i in range(N):
	(s, p) = input().split()
	P[i] = [s, -int(p), i + 1]
P.sort()
for i in range(N):
	print(P[i][2])


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


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


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


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


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, *SP) = open(0).read().split()
sp = sorted(((s, -int(p), i) for (i, (s, p)) in enumerate(zip(*[iter(SP)] * 2), 1)))
[print(i) for (_, _, i) in sp]


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())
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())
a = []
for i in range(n):
	(s, p) = input().split()
	a.append((s, -int(p), i))
a.sort()
for (_, _, i) in a:
	print(i + 1)


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


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


n = int(input())
l = []
for i in range(n):
	(a, b) = input().split()
	b = -1 * int(b)
	l.append([a, b, i + 1])
l = sorted(l)
for i in range(n):
	print(l[i][2])


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())
L = []
for i in range(N):
	(a, b) = input().split()
	L.append([a, 100 - int(b), i + 1])
L.sort()
for i in range(N):
	print(L[i][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())
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())
a = []
for i in range(n):
	(s, p) = input().split()
	a += [(s, -int(p), i + 1)]
a.sort()
{print(t[2]) for t in a}


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


N = int(input())
f = lambda i, x: (x[0], -int(x[1]), i)
R = sorted((f(i, input().split()) for i in range(N)))
for (_, _, i) in R:
	print(i + 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())
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())
r = []
for i in range(n):
	(c, s) = input().split()
	r.append((c, -int(s), i + 1))
r = sorted(r)
for x in r:
	print(x[2])


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


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


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


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


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())
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())
R = [[i + 1] + input().split() for i in range(N)]
R.sort(key=lambda x: (x[1], -int(x[2])))
for (r, _, _) in R:
	print(r)


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


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


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


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())
L = []
for i in range(N):
	(N, K) = input().split()
	K = int(K)
	L.append([N, -K, i + 1])
L.sort()
for i in L:
	print(i[2])


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


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


N = int(input())
ls = [list(input().split()) + [i] for i in range(N)]
ls.sort(key=lambda x: (x[0], -int(x[1])))
for i in range(N):
	print(ls[i][2] + 1)


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


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


n = int(input())
data = [tuple(input().split() + [i + 1]) for i in range(n)]
data.sort(key=lambda tup: (tup[0], -int(tup[1])))
for i in data:
	print(i[2])


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


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())
L = [input().split() + [i + 1] for i in range(N)]
L.sort(key=lambda x: (x[0], -int(x[1])))
print(*[n[2] for n in L], sep='\n')


((N,), *sp) = [s.split() for s in open(0)]
sp = [(s, -int(p), i + 1) for (i, (s, p)) in enumerate(sp)]
for (_, _, i) in sorted(sp):
	print(i)


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 a in A:
	print(a[2])


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


n = int(input())
S = [input().split() + [i + 1] for i in range(n)]
t = sorted(S, key=lambda x: [x[0], -int(x[1])])
for m in t:
	print(m[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())
ans = []
for i in range(N):
	(s, p) = input().split()
	ans += [[s, -int(p), i + 1]]
ans.sort()
for a in ans:
	print(a[2])


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


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


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())
SP = [list(input().split()) + [i] for i in range(n)]
SP.sort(key=lambda x: (x[0], -int(x[1])))
for (i, j, k) in SP:
	print(k + 1)


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


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 e in lst:
	print(e[2])


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())
List = [[i + 1] + input().split() for i in range(N)]
List.sort(key=lambda x: (x[1], -int(x[2])))
for (s, r, t) in List:
	print(s)


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


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)


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


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


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


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


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

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)


for (*_, i) in sorted(((t.split()[0], -int(t.split()[-1]), i) for (i, t) in enumerate(open(0))))[1:]:
	print(i)


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())
a = []
for i in range(n):
	(s, p) = input().split()
	a += [(s, -int(p), i + 1)]
for i in sorted(a):
	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 (s, p, k) in lst:
	print(k)


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


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


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())
X = []
for i in range(1, N + 1):
	(S, P) = input().split()
	X.append((S, -int(P), i))
X.sort()
for (_, _, c) in X:
	print(c)


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 = [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 ans:
	print(i[2])


N = int(input())
SPI = [input().split() + [i] for i in range(N)]
SPI.sort(key=lambda x: (x[0], -int(x[1])))
for (_, _, i) in SPI:
	print(i + 1)


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


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())
r = [input().split() + [i + 1] for i in range(n)]
o = sorted(r, key=lambda x: (x[0], -int(x[1])))
[print(o[i][2]) for i in range(n)]


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)


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


A = []
p = int(input())
for i in range(p):
	(j, k) = input().split()
	A.append([j, -int(k), i + 1])
A = sorted(A)
for (j, k, l) in A:
	print(l)


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


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


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


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())
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())
A = []
for i in range(N):
	(S, P) = input().split()
	A.append((S, -int(P), i))
A.sort()
print(*list((i + 1 for (_, _, i) in A)))


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


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


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


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


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


N = int(input())
spn = [[(s, -int(p)) for (s, p) in [input().split()]] + [i + 1] for i in range(N)]
spn.sort()
for (a, b) in spn:
	print(b)


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


N = int(input())
S = {}
for i in range(N):
	(p, q) = input().split()
	S[i + 1] = (p, int(q))
S = sorted(S, key=lambda x: (S[x][0], -S[x][1]))
print(*S, sep='\n')


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


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


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())
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)
for i in c:
	print(b.index(i) + 1)


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 = []
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])


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


n = int(input())
a = [list(input().split()) + [i] for i in range(n)]
for i in range(n):
	a[i][1] = -int(a[i][1])
a.sort()
for (_, _, i) in a:
	print(i + 1)


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


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


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


n = int(input())
a = (input().split() for _ in range(n))
for x in sorted(((s, -int(p), i) for (i, (s, p)) in enumerate(a, 1))):
	print(x[2])


l = []
for i in range(int(input())):
	(a, b) = input().split()
	l.append([a, -int(b), i + 1])
l.sort(key=lambda x: x[1])
l.sort()
for (a, b, c) in l:
	print(c)


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)