import sys

from collections import defaultdict



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60





def main():

    N = int(readline())

    d = defaultdict(list)

    for i in range(N):

        s, p = readline().strip().split()

        p = int(p)

        d[s].append((p, i+1))



    for city, points in sorted(d.items()):

        points = sorted(points, reverse=True)

        for _, i in points:

            print(i)



    return





if __name__ == '__main__':

    main()

import sys

from operator import itemgetter



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60





def main():

    N = int(readline())

    A = [0] * N

    for i in range(N):

        s, p = readline().strip().split()

        p = int(p)

        A[i] = (s, p, i + 1)



    A.sort(key=itemgetter(1), reverse=True)

    A.sort(key=itemgetter(0))

    for s, p, i in A:

        print(i)



    return





if __name__ == '__main__':

    main()

import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60


def main():
    N = int(readline())
    d = defaultdict(list)
    for i in range(N):
        s, p = readline().strip().split()
        p = int(p)
        d[s].append((p, i + 1))
    for city, points in sorted(d.items()):
        points = sorted(points, reverse=True)
        for _, i in points:
            print(i)
    return


if __name__ == "__main__":
    main()

import sys
from operator import itemgetter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60


def main():
    N = int(readline())
    A = [0] * N
    for i in range(N):
        s, p = readline().strip().split()
        p = int(p)
        A[i] = (s, p, i + 1)
    A.sort(key=itemgetter(1), reverse=True)
    A.sort(key=itemgetter(0))
    for s, p, i in A:
        print(i)
    return


if __name__ == "__main__":
    main()

-from collections import defaultdict +from operator import itemgetter -    d = defaultdict(list) +    A = [0] * N -        d[s].append((p, i + 1)) -    for city, points in sorted(d.items()): -        points = sorted(points, reverse=True) -        for _, i in points: -            print(i) +        A[i] = (s, p, i + 1) +    A.sort(key=itemgetter(1), reverse=True) +    A.sort(key=itemgetter(0)) +    for s, p, i in A: +        print(i)