import math

import copy



class Score:

    def set_data(self, town, score, idx):

        self.town = set_town

        self.score = set_score

        self.idx = set_idx



inputa = input().split()

# inputb = input().split()



a = int(inputa[0])

# b = int(inputa[1])

# c = int(inputa[2])



# x = int(inputb[0])

# y = int(inputb[1])



# inputList=[]

# for i in range(a):

#     inputNum = input()

#     inputList.append(inputNum)



inputList=[]

for i in range(a):

    inputItem = input().split()

    inputItem.append(i+1)

    inputList.append(inputItem)





# listb = []

# listb = [int(n) for n in inputb]



inputNameListSorted = []

tmp = sorted(inputList, key=lambda x:int(x[1]), reverse = True)

inputNameListSorted = sorted(tmp, key=lambda x:x[0])



for i in range(len(inputNameListSorted)):

    print((inputNameListSorted[i][2]))
import sys



# import math

# import bisect



# import copy

# import heapq

# from collections import deque

# import decimal



# sys.setrecursionlimit(100001)

# INF = sys.maxsize

# MOD = 10 ** 9 + 7



ni = lambda: int(sys.stdin.readline())

ns = lambda: list(map(int, sys.stdin.readline().split()))

na = lambda: list(map(int, sys.stdin.readline().split()))





# ===CODE===





def main():

    n = ni()

    d = []

    for i in range(n):

        s, p = input().split()

        d.append((s, int(p), i + 1))



    tmp = sorted(d, key=lambda x: x[1], reverse=True)

    tmp1 = sorted(tmp, key=lambda x: x[0])



    for t in tmp1:

        print((t[2]))





if __name__ == '__main__':

    main()

import math
import copy


class Score:
    def set_data(self, town, score, idx):
        self.town = set_town
        self.score = set_score
        self.idx = set_idx


inputa = input().split()
# inputb = input().split()
a = int(inputa[0])
# b = int(inputa[1])
# c = int(inputa[2])
# x = int(inputb[0])
# y = int(inputb[1])
# inputList=[]
# for i in range(a):
#     inputNum = input()
#     inputList.append(inputNum)
inputList = []
for i in range(a):
    inputItem = input().split()
    inputItem.append(i + 1)
    inputList.append(inputItem)
# listb = []
# listb = [int(n) for n in inputb]
inputNameListSorted = []
tmp = sorted(inputList, key=lambda x: int(x[1]), reverse=True)
inputNameListSorted = sorted(tmp, key=lambda x: x[0])
for i in range(len(inputNameListSorted)):
    print((inputNameListSorted[i][2]))

import sys

# import math
# import bisect
# import copy
# import heapq
# from collections import deque
# import decimal
# sys.setrecursionlimit(100001)
# INF = sys.maxsize
# MOD = 10 ** 9 + 7
ni = lambda: int(sys.stdin.readline())
ns = lambda: list(map(int, sys.stdin.readline().split()))
na = lambda: list(map(int, sys.stdin.readline().split()))
# ===CODE===
def main():
    n = ni()
    d = []
    for i in range(n):
        s, p = input().split()
        d.append((s, int(p), i + 1))
    tmp = sorted(d, key=lambda x: x[1], reverse=True)
    tmp1 = sorted(tmp, key=lambda x: x[0])
    for t in tmp1:
        print((t[2]))


if __name__ == "__main__":
    main()

-import math -import copy +import sys + +# import math +# import bisect +# import copy +# import heapq +# from collections import deque +# import decimal +# sys.setrecursionlimit(100001) +# INF = sys.maxsize +# MOD = 10 ** 9 + 7 +ni = lambda: int(sys.stdin.readline()) +ns = lambda: list(map(int, sys.stdin.readline().split())) +na = lambda: list(map(int, sys.stdin.readline().split())) +# ===CODE=== +def main(): +    n = ni() +    d = [] +    for i in range(n): +        s, p = input().split() +        d.append((s, int(p), i + 1)) +    tmp = sorted(d, key=lambda x: x[1], reverse=True) +    tmp1 = sorted(tmp, key=lambda x: x[0]) +    for t in tmp1: +        print((t[2])) -class Score: -    def set_data(self, town, score, idx): -        self.town = set_town -        self.score = set_score -        self.idx = set_idx - - -inputa = input().split() -# inputb = input().split() -a = int(inputa[0]) -# b = int(inputa[1]) -# c = int(inputa[2]) -# x = int(inputb[0]) -# y = int(inputb[1]) -# inputList=[] -# for i in range(a): -#     inputNum = input() -#     inputList.append(inputNum) -inputList = [] -for i in range(a): -    inputItem = input().split() -    inputItem.append(i + 1) -    inputList.append(inputItem) -# listb = [] -# listb = [int(n) for n in inputb] -inputNameListSorted = [] -tmp = sorted(inputList, key=lambda x: int(x[1]), reverse=True) -inputNameListSorted = sorted(tmp, key=lambda x: x[0]) -for i in range(len(inputNameListSorted)): -    print((inputNameListSorted[i][2])) +if __name__ == "__main__": +    main()