def main():
    n = int(input())
    l = []
    d = {}
    for i in range(n):
        s,p = input().split()
        if s not in l:
            l.append(s)
            d[s] = []
        d[s].append([int(p), i+1])
    
    for i in sorted(l):
        for j in sorted(d[i], reverse=True):
            print(j[1])
main()   def main():
    n = int(input())
    l = []
    d = {}
    for i in range(n):
        s,p = input().split()
        if s not in l:
            l.append(s)
            d[s] = []
        d[s].append([int(p), i+1])
    
    for i in sorted(l):
        for j in sorted(d[i], reverse=True):
            print(j[1]) main n = int(input()) n int(input()) int input() input l = [] l [] d = {} d {} for i in range(n):
        s,p = input().split()
        if s not in l:
            l.append(s)
            d[s] = []
        d[s].append([int(p), i+1])
    
     i range(n) range n s,p = input().split() s input().split() ().split () input split p if s not in l:
            l.append(s)
            d[s] = []
         s not in l s l l.append(s) l.append l append s d[s] = [] d[s] d s [] d[s].append([int(p), i+1]) [s].append [s] d s append [int(p), i+1] int(p) int p i+1 i 1 for i in sorted(l):
        for j in sorted(d[i], reverse=True):
            print(j[1]) i sorted(l) sorted l for j in sorted(d[i], reverse=True):
            print(j[1]) j sorted(d[i], reverse=True) sorted d[i] d i reverse=True reverse True print(j[1]) print j[1] j 1 main() main def main():
    n = int(input())
    l = []
    d = {}
    for i in range(n):
        s,p = input().split()
        if s not in l:
            l.append(s)
            d[s] = []
        d[s].append([int(p), i+1])
    
    for i in sorted(l):
        for j in sorted(d[i], reverse=True):
            print(j[1]) def main():
    n = int(input())
    l = []
    d = {}
    for i in range(n):
        s,p = input().split()
        if s not in l:
            l.append(s)
            d[s] = []
        d[s].append([int(p), i+1])
    
    for i in sorted(l):
        for j in sorted(d[i], reverse=True):
            print(j[1]) main
def main():
    n = int(input())
    l = []
    d = {}
    for i in range(n):
        s,p = input().split()
        if s not in l:
            l.append(s)
            d[s] = []
        d[s].append([int(p), i+1])
    
    for i in sorted(l):
        for j in sorted(d[i], reverse=True):
            print(j[1])
main()  