def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
ans = {}

for i in range(N):
    S, P = input().split()
    P = int(P)
    
    if S in ans.keys():
        ans[S].append([P, i + 1])
        ans[S].sort(key = lambda x : x[0], reverse = True)
    else:
        ans[S] = [[P, i + 1]]
    
store = list(ans.keys())
store.sort()

for s in store:
    for p in ans[s]:
        print(p[1]) def INT():
    return int(input()) INT return int(input()) int(input()) int input() input def MI():
    return map(int, input().split()) MI return map(int, input().split()) map(int, input().split()) map int input().split() ().split () input split def LI():
    return list(map(int, input().split())) LI return list(map(int, input().split())) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split N = INT() N INT() INT ans = {} ans {} for i in range(N):
    S, P = input().split()
    P = int(P)
    
    if S in ans.keys():
        ans[S].append([P, i + 1])
        ans[S].sort(key = lambda x : x[0], reverse = True)
    else:
        ans[S] = [[P, i + 1]]
     i range(N) range N S, P = input().split() S input().split() ().split () input split P P = int(P) P int(P) int P if S in ans.keys():
        ans[S].append([P, i + 1])
        ans[S].sort(key = lambda x : x[0], reverse = True)
    else:
        ans[S] = [[P, i + 1]]
     S in ans.keys() S ans.keys() ans.keys ans keys ans[S].append([P, i + 1]) [S].append [S] ans S append [P, i + 1] P i + 1 i 1 ans[S].sort(key = lambda x : x[0], reverse = True) [S].sort [S] ans S sort key = lambda x : x[0] key lambda x : x[0] x[0] x 0 x reverse = True reverse True ans[S] = [[P, i + 1]] ans[S] ans S [[P, i + 1]] [P, i + 1] P i + 1 i 1 store = list(ans.keys()) store list(ans.keys()) list ans.keys() ans.keys ans keys store.sort() store.sort store sort for s in store:
    for p in ans[s]:
        print(p[1]) s store for p in ans[s]:
        print(p[1]) p ans[s] ans s print(p[1]) print p[1] p 1 def MI():
    return map(int, input().split()) def MI():
    return map(int, input().split()) MI N = INT() INT() N ans = {} {} ans P = int(P) int(P) P P = input().split() input().split() P store = list(ans.keys()) list(ans.keys()) store def LI():
    return list(map(int, input().split())) def LI():
    return list(map(int, input().split())) LI S, P = input().split() input().split() S def INT():
    return int(input()) def INT():
    return int(input()) INT
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
ans = {}

for i in range(N):
    S, P = input().split()
    P = int(P)
    
    if S in ans.keys():
        ans[S].append([P, i + 1])
        ans[S].sort(key = lambda x : x[0], reverse = True)
    else:
        ans[S] = [[P, i + 1]]
    
store = list(ans.keys())
store.sort()

for s in store:
    for p in ans[s]:
        print(p[1])