N = int(eval(input()))



a = []

for i in range(1, N + 1):

    s, p = input().split()

    a.append((s, int(p), i))

a.sort(key=lambda x: (x[0], -x[1]))

# 市昇順, 点数降順



for _, _, i in a:

    print(i)

def main():

    from collections import defaultdict



    book = defaultdict(list)

    N = int(eval(input()))

    for ind in range(1, N + 1):

        s, p = input().split()

        book[s].append((int(p), ind))



    for s in sorted(book.keys()):

        book[s].sort(key=lambda x: x[0], reverse=True)

        for _, ind in book[s]:

            print(ind)





if __name__ == '__main__':

    main()

N = int(eval(input()))
a = []
for i in range(1, N + 1):
    s, p = input().split()
    a.append((s, int(p), i))
a.sort(key=lambda x: (x[0], -x[1]))
# 市昇順, 点数降順
for _, _, i in a:
    print(i)

def main():
    from collections import defaultdict

    book = defaultdict(list)
    N = int(eval(input()))
    for ind in range(1, N + 1):
        s, p = input().split()
        book[s].append((int(p), ind))
    for s in sorted(book.keys()):
        book[s].sort(key=lambda x: x[0], reverse=True)
        for _, ind in book[s]:
            print(ind)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -a = [] -for i in range(1, N + 1): -    s, p = input().split() -    a.append((s, int(p), i)) -a.sort(key=lambda x: (x[0], -x[1])) -# 市昇順, 点数降順 -for _, _, i in a: -    print(i) +def main(): +    from collections import defaultdict + +    book = defaultdict(list) +    N = int(eval(input())) +    for ind in range(1, N + 1): +        s, p = input().split() +        book[s].append((int(p), ind)) +    for s in sorted(book.keys()): +        book[s].sort(key=lambda x: x[0], reverse=True) +        for _, ind in book[s]: +            print(ind) + + +if __name__ == "__main__": +    main()