from operator import itemgetter

n=int(eval(input()))

y,s=list(),list()

for i in range(1,n+1):

	S=input().split()

	S[1]=int(S[1])

	S.append(i)

	s.append(S)

y=sorted(s,key=itemgetter(0))

for i in range(n):

	for j in range(1,n):

		if((y[j-1][0]==y[j][0])&(y[j-1][1]<y[j][1])): y[j-1],y[j]=y[j],y[j-1]

for i in range(n):

	print((y[i][2]))
from operator import itemgetter

n=int(eval(input()))

y,s=list(),list()

for i in range(1,n+1):

	S=input().split()

	S[1]=int(S[1])

	S.append(i)

	s.append(S)

y=sorted(s,key=itemgetter(0))

for i in range(n):

	c=0

	for j in range(1,n):

		if((y[j-1][0]==y[j][0])&(y[j-1][1]<y[j][1])):

			y[j-1],y[j]=y[j],y[j-1]

			c=1

	if c==0:break

for i in range(n):

	print((y[i][2]))
from operator import itemgetter

n = int(eval(input()))
y, s = list(), list()
for i in range(1, n + 1):
    S = input().split()
    S[1] = int(S[1])
    S.append(i)
    s.append(S)
y = sorted(s, key=itemgetter(0))
for i in range(n):
    for j in range(1, n):
        if (y[j - 1][0] == y[j][0]) & (y[j - 1][1] < y[j][1]):
            y[j - 1], y[j] = y[j], y[j - 1]
for i in range(n):
    print((y[i][2]))

from operator import itemgetter

n = int(eval(input()))
y, s = list(), list()
for i in range(1, n + 1):
    S = input().split()
    S[1] = int(S[1])
    S.append(i)
    s.append(S)
y = sorted(s, key=itemgetter(0))
for i in range(n):
    c = 0
    for j in range(1, n):
        if (y[j - 1][0] == y[j][0]) & (y[j - 1][1] < y[j][1]):
            y[j - 1], y[j] = y[j], y[j - 1]
            c = 1
    if c == 0:
        break
for i in range(n):
    print((y[i][2]))

+    c = 0 +            c = 1 +    if c == 0: +        break