def main():
    N = int(input())
    s_dict = dict()

    for i in range(1, N + 1):
        S, P = input().split()
        if S in s_dict:
            s_dict[S].append((i, int(P)))
        else:
            s_dict[S] = [(i, int(P))]

    s_dict_keys = sorted(list(s_dict.keys()))

    for key in s_dict_keys:
        s_dict[key].sort(key=lambda x: x[1], reverse=True)
        for i, _ in s_dict[key]:
            print(i)


if __name__ == "__main__":
    main() def main():
    N = int(input())
    s_dict = dict()

    for i in range(1, N + 1):
        S, P = input().split()
        if S in s_dict:
            s_dict[S].append((i, int(P)))
        else:
            s_dict[S] = [(i, int(P))]

    s_dict_keys = sorted(list(s_dict.keys()))

    for key in s_dict_keys:
        s_dict[key].sort(key=lambda x: x[1], reverse=True)
        for i, _ in s_dict[key]:
            print(i) main N = int(input()) N int(input()) int input() input s_dict = dict() s_dict dict() dict for i in range(1, N + 1):
        S, P = input().split()
        if S in s_dict:
            s_dict[S].append((i, int(P)))
        else:
            s_dict[S] = [(i, int(P))]

     i range(1, N + 1) range 1 N + 1 N 1 S, P = input().split() S input().split() ().split () input split P if S in s_dict:
            s_dict[S].append((i, int(P)))
        else:
            s_dict[S] = [(i, int(P))]

     S in s_dict S s_dict s_dict[S].append((i, int(P))) [S].append [S] s_dict S append (i, int(P)) i int(P) int P s_dict[S] = [(i, int(P))] s_dict[S] s_dict S [(i, int(P))] (i, int(P)) i int(P) int P s_dict_keys = sorted(list(s_dict.keys())) s_dict_keys sorted(list(s_dict.keys())) sorted list(s_dict.keys()) list s_dict.keys() s_dict.keys s_dict keys for key in s_dict_keys:
        s_dict[key].sort(key=lambda x: x[1], reverse=True)
        for i, _ in s_dict[key]:
            print(i) key s_dict_keys s_dict[key].sort(key=lambda x: x[1], reverse=True) [key].sort [key] s_dict key sort key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x reverse=True reverse True for i, _ in s_dict[key]:
            print(i) i _ s_dict[key] s_dict key print(i) print i if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    s_dict = dict()

    for i in range(1, N + 1):
        S, P = input().split()
        if S in s_dict:
            s_dict[S].append((i, int(P)))
        else:
            s_dict[S] = [(i, int(P))]

    s_dict_keys = sorted(list(s_dict.keys()))

    for key in s_dict_keys:
        s_dict[key].sort(key=lambda x: x[1], reverse=True)
        for i, _ in s_dict[key]:
            print(i) def main():
    N = int(input())
    s_dict = dict()

    for i in range(1, N + 1):
        S, P = input().split()
        if S in s_dict:
            s_dict[S].append((i, int(P)))
        else:
            s_dict[S] = [(i, int(P))]

    s_dict_keys = sorted(list(s_dict.keys()))

    for key in s_dict_keys:
        s_dict[key].sort(key=lambda x: x[1], reverse=True)
        for i, _ in s_dict[key]:
            print(i) main
def main():
    N = int(input())
    s_dict = dict()

    for i in range(1, N + 1):
        S, P = input().split()
        if S in s_dict:
            s_dict[S].append((i, int(P)))
        else:
            s_dict[S] = [(i, int(P))]

    s_dict_keys = sorted(list(s_dict.keys()))

    for key in s_dict_keys:
        s_dict[key].sort(key=lambda x: x[1], reverse=True)
        for i, _ in s_dict[key]:
            print(i)


if __name__ == "__main__":
    main()
