def main():
    N = int(input())
    sp_lst = [0 for _ in range(N)]

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

    sp_lst.sort(key=lambda x: x[2], reverse=True)
    sp_lst.sort(key=lambda x: x[1])

    for i, _, _ in sp_lst:
        print(i)


if __name__ == "__main__":
    main() def main():
    N = int(input())
    sp_lst = [0 for _ in range(N)]

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

    sp_lst.sort(key=lambda x: x[2], reverse=True)
    sp_lst.sort(key=lambda x: x[1])

    for i, _, _ in sp_lst:
        print(i) main N = int(input()) N int(input()) int input() input 0 for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) 0 sp_lst = [0 for _ in range(N)] sp_lst [0 for _ in range(N)] for i in range(N):
        S, P = input().split()
        sp_lst[i] = [i + 1, S, int(P)]

     i range(N) range N S, P = input().split() S input().split() ().split () input split P sp_lst[i] = [i + 1, S, int(P)] sp_lst[i] sp_lst i [i + 1, S, int(P)] i + 1 i 1 S int(P) int P sp_lst.sort(key=lambda x: x[2], reverse=True) sp_lst.sort sp_lst sort key=lambda x: x[2] key lambda x: x[2] x[2] x 2 x reverse=True reverse True sp_lst.sort(key=lambda x: x[1]) sp_lst.sort sp_lst sort key=lambda x: x[1] key lambda x: x[1] x[1] x 1 x for i, _, _ in sp_lst:
        print(i) i _ _ sp_lst print(i) print i if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N = int(input())
    sp_lst = [0 for _ in range(N)]

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

    sp_lst.sort(key=lambda x: x[2], reverse=True)
    sp_lst.sort(key=lambda x: x[1])

    for i, _, _ in sp_lst:
        print(i) def main():
    N = int(input())
    sp_lst = [0 for _ in range(N)]

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

    sp_lst.sort(key=lambda x: x[2], reverse=True)
    sp_lst.sort(key=lambda x: x[1])

    for i, _, _ in sp_lst:
        print(i) main
def main():
    N = int(input())
    sp_lst = [0 for _ in range(N)]

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

    sp_lst.sort(key=lambda x: x[2], reverse=True)
    sp_lst.sort(key=lambda x: x[1])

    for i, _, _ in sp_lst:
        print(i)


if __name__ == "__main__":
    main()
