def irekae(array2):

    return [array2[1],array2[0],array2[2]]



n=int(eval(input()))

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

"""

# print(l)

for i in range(len(l)):

    l[i].append(i+1)

    l[i][1]=int(l[i][1])

# print(l)

l.sort()

# print(l)

for i in range(len(l)):

    l[i]=irekae(l[i])

# print(l)

lsort=[]

while l!=[]:

    """

for i in range(len(l)):

    l[i].append(i+1)

    l[i][1]=int(l[i][1])

for i in range(len(l)):

    l[i]=irekae(l[i])

#print(l)

l.sort(reverse=True)

#print(l)

for i in range(len(l)):

    l[i]=irekae(l[i])

#print(l)



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

#print(lx)

for i in range(len(lx)):

    print((lx[i][2]))
def irekae(array2):

    return [array2[1],array2[0],array2[2]]

n=int(eval(input()))

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

for i in range(len(l)):

    l[i].append(i+1)

    l[i][1]=int(l[i][1])

for i in range(len(l)):

    l[i]=irekae(l[i])

l.sort(reverse=True)

for i in range(len(l)):

    l[i]=irekae(l[i])

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

for i in range(len(lx)):

    print((lx[i][2]))
def irekae(array2):
    return [array2[1], array2[0], array2[2]]


n = int(eval(input()))
l = [input().split() for i in range(n)]
"""
# print(l)
for i in range(len(l)):
    l[i].append(i+1)
    l[i][1]=int(l[i][1])
# print(l)
l.sort()
# print(l)
for i in range(len(l)):
    l[i]=irekae(l[i])
# print(l)
lsort=[]
while l!=[]:
    """
for i in range(len(l)):
    l[i].append(i + 1)
    l[i][1] = int(l[i][1])
for i in range(len(l)):
    l[i] = irekae(l[i])
# print(l)
l.sort(reverse=True)
# print(l)
for i in range(len(l)):
    l[i] = irekae(l[i])
# print(l)
lx = sorted(l, key=lambda x: x[0])
# print(lx)
for i in range(len(lx)):
    print((lx[i][2]))

def irekae(array2):
    return [array2[1], array2[0], array2[2]]


n = int(eval(input()))
l = [input().split() for i in range(n)]
for i in range(len(l)):
    l[i].append(i + 1)
    l[i][1] = int(l[i][1])
for i in range(len(l)):
    l[i] = irekae(l[i])
l.sort(reverse=True)
for i in range(len(l)):
    l[i] = irekae(l[i])
lx = sorted(l, key=lambda x: x[0])
for i in range(len(lx)):
    print((lx[i][2]))

-""" -# print(l) -for i in range(len(l)): -    l[i].append(i+1) -    l[i][1]=int(l[i][1]) -# print(l) -l.sort() -# print(l) -for i in range(len(l)): -    l[i]=irekae(l[i]) -# print(l) -lsort=[] -while l!=[]: -    """ -# print(l) -# print(l) -# print(l) -# print(lx)