def main(N, lst):

    L = []

    for i in range(len(lst)):

        target = lst[i]

        L.append({"id":i+1, "store":target[0], "point":int(target[1])})

        L.sort(key = lambda x:x["point"], reverse = True)

        L.sort(key = lambda x:x["store"])

    for i in range(len(L)):

        print((L[i]["id"]))



N = int(eval(input()))

lst = list(list(map(str, input().split())) for _ in range(N))

main(N, lst)
def main(N, lst):

    L = []

    for i in range(len(lst)):

        target = lst[i]

        L.append({"id":i+1, "store":target[0], "point":int(target[1])})

    L.sort(key = lambda x:x["point"], reverse = True)

    L.sort(key = lambda x:x["store"])

    for i in range(len(L)):

        print((L[i]["id"]))



N = int(eval(input()))

lst = list(list(map(str, input().split())) for _ in range(N))

main(N, lst)
def main(N, lst):
    L = []
    for i in range(len(lst)):
        target = lst[i]
        L.append({"id": i + 1, "store": target[0], "point": int(target[1])})
        L.sort(key=lambda x: x["point"], reverse=True)
        L.sort(key=lambda x: x["store"])
    for i in range(len(L)):
        print((L[i]["id"]))


N = int(eval(input()))
lst = list(list(map(str, input().split())) for _ in range(N))
main(N, lst)

def main(N, lst):
    L = []
    for i in range(len(lst)):
        target = lst[i]
        L.append({"id": i + 1, "store": target[0], "point": int(target[1])})
    L.sort(key=lambda x: x["point"], reverse=True)
    L.sort(key=lambda x: x["store"])
    for i in range(len(L)):
        print((L[i]["id"]))


N = int(eval(input()))
lst = list(list(map(str, input().split())) for _ in range(N))
main(N, lst)

-        L.sort(key=lambda x: x["point"], reverse=True) -        L.sort(key=lambda x: x["store"]) +    L.sort(key=lambda x: x["point"], reverse=True) +    L.sort(key=lambda x: x["store"])