#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [0] * N
    P = [0] * N
    R = [0] * N
    for i in range(N):
        S[i] , P[i] = map(str, input().split())
    for i in range(N):
        R[i] = i + 1
    for i in range(N):
        P[i] = int(P[i]) * -1


    Z = zip(S, P, R)
    Z = sorted(Z)
    S, P, R = zip(*Z)

    for i in R:
        print(i)

if __name__ == '__main__':
    main() import sys sys def input():
    return sys.stdin.readline()[:-1] input return sys.stdin.readline()[:-1] sys.stdin.readline()[:-1] sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline :-1 -1 def main():
    N = int(input())
    S = [0] * N
    P = [0] * N
    R = [0] * N
    for i in range(N):
        S[i] , P[i] = map(str, input().split())
    for i in range(N):
        R[i] = i + 1
    for i in range(N):
        P[i] = int(P[i]) * -1


    Z = zip(S, P, R)
    Z = sorted(Z)
    S, P, R = zip(*Z)

    for i in R:
        print(i) main N = int(input()) N int(input()) int input() input S = [0] * N S [0] * N [0] 0 N P = [0] * N P [0] * N [0] 0 N R = [0] * N R [0] * N [0] 0 N for i in range(N):
        S[i] , P[i] = map(str, input().split())
     i range(N) range N S[i] , P[i] = map(str, input().split()) S[i] S i map(str, input().split()) map str input().split() ().split () input split P[i] P i for i in range(N):
        R[i] = i + 1
     i range(N) range N R[i] = i + 1 R[i] R i i + 1 i 1 for i in range(N):
        P[i] = int(P[i]) * -1


     i range(N) range N P[i] = int(P[i]) * -1 P[i] P i int(P[i]) * -1 int(P[i]) int P[i] P i -1 Z = zip(S, P, R) Z zip(S, P, R) zip S P R Z = sorted(Z) Z sorted(Z) sorted Z S, P, R = zip(*Z) S zip(*Z) zip *Z Z P R for i in R:
        print(i) i R print(i) print i if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def input():
    return sys.stdin.readline()[:-1] def input():
    return sys.stdin.readline()[:-1] input def main():
    N = int(input())
    S = [0] * N
    P = [0] * N
    R = [0] * N
    for i in range(N):
        S[i] , P[i] = map(str, input().split())
    for i in range(N):
        R[i] = i + 1
    for i in range(N):
        P[i] = int(P[i]) * -1


    Z = zip(S, P, R)
    Z = sorted(Z)
    S, P, R = zip(*Z)

    for i in R:
        print(i) def main():
    N = int(input())
    S = [0] * N
    P = [0] * N
    R = [0] * N
    for i in range(N):
        S[i] , P[i] = map(str, input().split())
    for i in range(N):
        R[i] = i + 1
    for i in range(N):
        P[i] = int(P[i]) * -1


    Z = zip(S, P, R)
    Z = sorted(Z)
    S, P, R = zip(*Z)

    for i in R:
        print(i) main
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    N = int(input())
    S = [0] * N
    P = [0] * N
    R = [0] * N
    for i in range(N):
        S[i] , P[i] = map(str, input().split())
    for i in range(N):
        R[i] = i + 1
    for i in range(N):
        P[i] = int(P[i]) * -1


    Z = zip(S, P, R)
    Z = sorted(Z)
    S, P, R = zip(*Z)

    for i in R:
        print(i)

if __name__ == '__main__':
    main()
