def main():
    n = int(input())
    sp_lst = [0] * n
    for i in range(n):
        sp_lst[i] = list(map(str, input().split()))

    turn_lst = []
    city_lst = []
    for i in range(n):
        city_lst.append(sp_lst[i][0])
    city_lst = list(set(city_lst))
    city_lst.sort()

    number_of_cities = len(city_lst)
    for i in range(number_of_cities):
        city = city_lst[i]
        score_lst = []
        for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

        score_lst = sorted(score_lst)
        score_lst.reverse()
        number_of_score = len(score_lst)
        for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

    for i in range(n):
        print(turn_lst[i])

if __name__ == "__main__":
    main() def main():
    n = int(input())
    sp_lst = [0] * n
    for i in range(n):
        sp_lst[i] = list(map(str, input().split()))

    turn_lst = []
    city_lst = []
    for i in range(n):
        city_lst.append(sp_lst[i][0])
    city_lst = list(set(city_lst))
    city_lst.sort()

    number_of_cities = len(city_lst)
    for i in range(number_of_cities):
        city = city_lst[i]
        score_lst = []
        for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

        score_lst = sorted(score_lst)
        score_lst.reverse()
        number_of_score = len(score_lst)
        for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

    for i in range(n):
        print(turn_lst[i]) main n = int(input()) n int(input()) int input() input sp_lst = [0] * n sp_lst [0] * n [0] 0 n for i in range(n):
        sp_lst[i] = list(map(str, input().split()))

     i range(n) range n sp_lst[i] = list(map(str, input().split())) sp_lst[i] sp_lst i list(map(str, input().split())) list map(str, input().split()) map str input().split() ().split () input split turn_lst = [] turn_lst [] city_lst = [] city_lst [] for i in range(n):
        city_lst.append(sp_lst[i][0])
     i range(n) range n city_lst.append(sp_lst[i][0]) city_lst.append city_lst append sp_lst[i][0] [i] sp_lst i 0 city_lst = list(set(city_lst)) city_lst list(set(city_lst)) list set(city_lst) set city_lst city_lst.sort() city_lst.sort city_lst sort number_of_cities = len(city_lst) number_of_cities len(city_lst) len city_lst for i in range(number_of_cities):
        city = city_lst[i]
        score_lst = []
        for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

        score_lst = sorted(score_lst)
        score_lst.reverse()
        number_of_score = len(score_lst)
        for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

     i range(number_of_cities) range number_of_cities city = city_lst[i] city city_lst[i] city_lst i score_lst = [] score_lst [] for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

         j range(n) range n if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

         city == sp_lst[j][0] city sp_lst[j][0] [j] sp_lst j 0 score_lst.append(int(sp_lst[j][1])) score_lst.append score_lst append int(sp_lst[j][1]) int sp_lst[j][1] [j] sp_lst j 1 score_lst = sorted(score_lst) score_lst sorted(score_lst) sorted score_lst score_lst.reverse() score_lst.reverse score_lst reverse number_of_score = len(score_lst) number_of_score len(score_lst) len score_lst for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

     k range(number_of_score) range number_of_score score = str(score_lst[k]) score str(score_lst[k]) str score_lst[k] score_lst k turn_lst.append(sp_lst.index([city, score]) + 1) turn_lst.append turn_lst append sp_lst.index([city, score]) + 1 sp_lst.index([city, score]) sp_lst.index sp_lst index [city, score] city score 1 for i in range(n):
        print(turn_lst[i]) i range(n) range n print(turn_lst[i]) print turn_lst[i] turn_lst i if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    sp_lst = [0] * n
    for i in range(n):
        sp_lst[i] = list(map(str, input().split()))

    turn_lst = []
    city_lst = []
    for i in range(n):
        city_lst.append(sp_lst[i][0])
    city_lst = list(set(city_lst))
    city_lst.sort()

    number_of_cities = len(city_lst)
    for i in range(number_of_cities):
        city = city_lst[i]
        score_lst = []
        for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

        score_lst = sorted(score_lst)
        score_lst.reverse()
        number_of_score = len(score_lst)
        for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

    for i in range(n):
        print(turn_lst[i]) def main():
    n = int(input())
    sp_lst = [0] * n
    for i in range(n):
        sp_lst[i] = list(map(str, input().split()))

    turn_lst = []
    city_lst = []
    for i in range(n):
        city_lst.append(sp_lst[i][0])
    city_lst = list(set(city_lst))
    city_lst.sort()

    number_of_cities = len(city_lst)
    for i in range(number_of_cities):
        city = city_lst[i]
        score_lst = []
        for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

        score_lst = sorted(score_lst)
        score_lst.reverse()
        number_of_score = len(score_lst)
        for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

    for i in range(n):
        print(turn_lst[i]) main
def main():
    n = int(input())
    sp_lst = [0] * n
    for i in range(n):
        sp_lst[i] = list(map(str, input().split()))

    turn_lst = []
    city_lst = []
    for i in range(n):
        city_lst.append(sp_lst[i][0])
    city_lst = list(set(city_lst))
    city_lst.sort()

    number_of_cities = len(city_lst)
    for i in range(number_of_cities):
        city = city_lst[i]
        score_lst = []
        for j in range(n):
            if city == sp_lst[j][0]:
                score_lst.append(int(sp_lst[j][1]))

        score_lst = sorted(score_lst)
        score_lst.reverse()
        number_of_score = len(score_lst)
        for k in range(number_of_score):
            score = str(score_lst[k])
            turn_lst.append(sp_lst.index([city, score]) + 1)

    for i in range(n):
        print(turn_lst[i])

if __name__ == "__main__":
    main()