n = int(input())
list = []
for xi in range(n):
    add1, add2 = input().split()
    add = [int(add2), add1, xi+1]
    list.append(add)
list.sort(key=lambda list2: list2[1])


name = list[0][1]
list2 = [list[0]]
count = 1
for xi in range(1,n):
    if name == list[xi][1]:
        list2.append(list[xi])
        count += 1
    else:
        list2.sort()
        for yi in range(count-1,-1,-1):
            print(list2[yi][2])
        name = list[xi][1]
        list2 = [list[xi]]
        count = 1

if len(list2)<n:
    list2.sort()
for yi in range(count-1,-1,-1):
    print(list2[yi][2])
name = list[xi][1]
list2 = [list[xi]]
count = 1 n = int(input()) n int(input()) int input() input list = [] list [] for xi in range(n):
    add1, add2 = input().split()
    add = [int(add2), add1, xi+1]
    list.append(add) xi range(n) range n add1, add2 = input().split() add1 input().split() ().split () input split add2 add = [int(add2), add1, xi+1] add [int(add2), add1, xi+1] int(add2) int add2 add1 xi+1 xi 1 list.append(add) list.append list append add list.sort(key=lambda list2: list2[1]) list.sort list sort key=lambda list2: list2[1] key lambda list2: list2[1] list2[1] list2 1 list2 name = list[0][1] name list[0][1] [0] list 0 1 list2 = [list[0]] list2 [list[0]] list[0] list 0 count = 1 count 1 for xi in range(1,n):
    if name == list[xi][1]:
        list2.append(list[xi])
        count += 1
    else:
        list2.sort()
        for yi in range(count-1,-1,-1):
            print(list2[yi][2])
        name = list[xi][1]
        list2 = [list[xi]]
        count = 1 xi range(1,n) range 1 n if name == list[xi][1]:
        list2.append(list[xi])
        count += 1
    else:
        list2.sort()
        for yi in range(count-1,-1,-1):
            print(list2[yi][2])
        name = list[xi][1]
        list2 = [list[xi]]
        count = 1 name == list[xi][1] name list[xi][1] [xi] list xi 1 list2.append(list[xi]) list2.append list2 append list[xi] list xi count += 1 count 1 list2.sort() list2.sort list2 sort for yi in range(count-1,-1,-1):
            print(list2[yi][2])
         yi range(count-1,-1,-1) range count-1 count 1 -1 -1 print(list2[yi][2]) print list2[yi][2] [yi] list2 yi 2 name = list[xi][1] name list[xi][1] [xi] list xi 1 list2 = [list[xi]] list2 [list[xi]] list[xi] list xi count = 1 count 1 if len(list2)<n:
    list2.sort() len(list2)<n len(list2) len list2 n list2.sort() list2.sort list2 sort for yi in range(count-1,-1,-1):
    print(list2[yi][2]) yi range(count-1,-1,-1) range count-1 count 1 -1 -1 print(list2[yi][2]) print list2[yi][2] [yi] list2 yi 2 name = list[xi][1] name list[xi][1] [xi] list xi 1 list2 = [list[xi]] list2 [list[xi]] list[xi] list xi count = 1 count 1 add1, add2 = input().split() input().split() add1 count = 1 1 count name = list[xi][1] list[xi][1] name count = 1 1 count count += 1 1 count name = list[0][1] list[0][1] name list2 = [list[xi]] [list[xi]] list2 count = 1 1 count add2 = input().split() input().split() add2 name = list[xi][1] list[xi][1] name n = int(input()) int(input()) n list = [] [] list add = [int(add2), add1, xi+1] [int(add2), add1, xi+1] add list2 = [list[xi]] [list[xi]] list2 list2 = [list[0]] [list[0]] list2
n = int(input())
list = []
for xi in range(n):
    add1, add2 = input().split()
    add = [int(add2), add1, xi+1]
    list.append(add)
list.sort(key=lambda list2: list2[1])


name = list[0][1]
list2 = [list[0]]
count = 1
for xi in range(1,n):
    if name == list[xi][1]:
        list2.append(list[xi])
        count += 1
    else:
        list2.sort()
        for yi in range(count-1,-1,-1):
            print(list2[yi][2])
        name = list[xi][1]
        list2 = [list[xi]]
        count = 1

if len(list2)<n:
    list2.sort()
for yi in range(count-1,-1,-1):
    print(list2[yi][2])
name = list[xi][1]
list2 = [list[xi]]
count = 1
