import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    dic = collections.defaultdict(list)
    for i in range(n):
        s, p = LS()
        p = int(p)

        dic[s].append((p,i+1))
    
    key = list(dic.keys())
    key.sort()
    for k in key:
        lst = dic[k]
        lst.sort(reverse=True)
        lst = list(zip(*lst))[1]
        for s in lst:
            print(s)

    
    
main() import bisect,collections,copy,itertools,math,string bisect collections copy itertools math string import sys sys def I(): return int(sys.stdin.readline().rstrip()) I def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def S(): return sys.stdin.readline().rstrip() S def LS(): return list(sys.stdin.readline().rstrip().split()) LS def main():
    n = I()
    dic = collections.defaultdict(list)
    for i in range(n):
        s, p = LS()
        p = int(p)

        dic[s].append((p,i+1))
    
    key = list(dic.keys())
    key.sort()
    for k in key:
        lst = dic[k]
        lst.sort(reverse=True)
        lst = list(zip(*lst))[1]
        for s in lst:
            print(s)

    
     main n = I() n I() I dic = collections.defaultdict(list) dic collections.defaultdict(list) collections.defaultdict collections defaultdict list for i in range(n):
        s, p = LS()
        p = int(p)

        dic[s].append((p,i+1))
    
     i range(n) range n s, p = LS() s LS() LS p p = int(p) p int(p) int p dic[s].append((p,i+1)) [s].append [s] dic s append (p,i+1) p i+1 i 1 key = list(dic.keys()) key list(dic.keys()) list dic.keys() dic.keys dic keys key.sort() key.sort key sort for k in key:
        lst = dic[k]
        lst.sort(reverse=True)
        lst = list(zip(*lst))[1]
        for s in lst:
            print(s)

    
     k key lst = dic[k] lst dic[k] dic k lst.sort(reverse=True) lst.sort lst sort reverse=True reverse True lst = list(zip(*lst))[1] lst list(zip(*lst))[1] (zip(*lst)) list zip(*lst) zip *lst lst 1 for s in lst:
            print(s)

    
     s lst print(s) print s main() main def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I def LS(): return list(sys.stdin.readline().rstrip().split()) def LS(): return list(sys.stdin.readline().rstrip().split()) LS def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def main():
    n = I()
    dic = collections.defaultdict(list)
    for i in range(n):
        s, p = LS()
        p = int(p)

        dic[s].append((p,i+1))
    
    key = list(dic.keys())
    key.sort()
    for k in key:
        lst = dic[k]
        lst.sort(reverse=True)
        lst = list(zip(*lst))[1]
        for s in lst:
            print(s)

    
     def main():
    n = I()
    dic = collections.defaultdict(list)
    for i in range(n):
        s, p = LS()
        p = int(p)

        dic[s].append((p,i+1))
    
    key = list(dic.keys())
    key.sort()
    for k in key:
        lst = dic[k]
        lst.sort(reverse=True)
        lst = list(zip(*lst))[1]
        for s in lst:
            print(s)

    
     main
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    dic = collections.defaultdict(list)
    for i in range(n):
        s, p = LS()
        p = int(p)

        dic[s].append((p,i+1))
    
    key = list(dic.keys())
    key.sort()
    for k in key:
        lst = dic[k]
        lst.sort(reverse=True)
        lst = list(zip(*lst))[1]
        for s in lst:
            print(s)

    
    
main()
