def resolve():
    N = int(input())
    city = []
    for i in range(N):
        s, p = input().split()
        city.append([s, int(p), i+1])
    city.sort(key = lambda city : (city[0], -city[1]))
    for j in range(N):
        print(city[j][2])
resolve() def resolve():
    N = int(input())
    city = []
    for i in range(N):
        s, p = input().split()
        city.append([s, int(p), i+1])
    city.sort(key = lambda city : (city[0], -city[1]))
    for j in range(N):
        print(city[j][2]) resolve N = int(input()) N int(input()) int input() input city = [] city [] for i in range(N):
        s, p = input().split()
        city.append([s, int(p), i+1])
     i range(N) range N s, p = input().split() s input().split() ().split () input split p city.append([s, int(p), i+1]) city.append city append [s, int(p), i+1] s int(p) int p i+1 i 1 city.sort(key = lambda city : (city[0], -city[1])) city.sort city sort key = lambda city : (city[0], -city[1]) key lambda city : (city[0], -city[1]) (city[0], -city[1]) city[0] city 0 -city[1] city[1] city 1 city for j in range(N):
        print(city[j][2]) j range(N) range N print(city[j][2]) print city[j][2] [j] city j 2 resolve() resolve def resolve():
    N = int(input())
    city = []
    for i in range(N):
        s, p = input().split()
        city.append([s, int(p), i+1])
    city.sort(key = lambda city : (city[0], -city[1]))
    for j in range(N):
        print(city[j][2]) def resolve():
    N = int(input())
    city = []
    for i in range(N):
        s, p = input().split()
        city.append([s, int(p), i+1])
    city.sort(key = lambda city : (city[0], -city[1]))
    for j in range(N):
        print(city[j][2]) resolve
def resolve():
    N = int(input())
    city = []
    for i in range(N):
        s, p = input().split()
        city.append([s, int(p), i+1])
    city.sort(key = lambda city : (city[0], -city[1]))
    for j in range(N):
        print(city[j][2])
resolve()