import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()

    city = []
    dic = {}
    for i in range(N):
        S,P=isp()
        P = int(P)
        if not S in city:
            city.append(S)
            dic[S] = [(P,i)]
        else:
            dic[S].append((P,i))
    
    city.sort()
    for S in city:
        Ps = dic[S]
        Ps.sort(reverse=True) 
        for p,i in Ps:
            print(i+1)
    


if __name__ == "__main__":
    main() import sys sys sys.setrecursionlimit(10**9) sys.setrecursionlimit sys setrecursionlimit 10**9 10 9 def mi(): return map(int,input().split()) mi def ii(): return int(input()) ii def isp(): return input().split() isp def deb(text): print("-------\n{}\n-------".format(text)) deb text text INF=10**20 INF 10**20 10 20 def main():
    N=ii()

    city = []
    dic = {}
    for i in range(N):
        S,P=isp()
        P = int(P)
        if not S in city:
            city.append(S)
            dic[S] = [(P,i)]
        else:
            dic[S].append((P,i))
    
    city.sort()
    for S in city:
        Ps = dic[S]
        Ps.sort(reverse=True) 
        for p,i in Ps:
            print(i+1)
     main N=ii() N ii() ii city = [] city [] dic = {} dic {} for i in range(N):
        S,P=isp()
        P = int(P)
        if not S in city:
            city.append(S)
            dic[S] = [(P,i)]
        else:
            dic[S].append((P,i))
    
     i range(N) range N S,P=isp() S isp() isp P P = int(P) P int(P) int P if not S in city:
            city.append(S)
            dic[S] = [(P,i)]
        else:
            dic[S].append((P,i))
    
     not S in city S in city S city city.append(S) city.append city append S dic[S] = [(P,i)] dic[S] dic S [(P,i)] (P,i) P i dic[S].append((P,i)) [S].append [S] dic S append (P,i) P i city.sort() city.sort city sort for S in city:
        Ps = dic[S]
        Ps.sort(reverse=True) 
        for p,i in Ps:
            print(i+1)
     S city Ps = dic[S] Ps dic[S] dic S Ps.sort(reverse=True) Ps.sort Ps sort reverse=True reverse True for p,i in Ps:
            print(i+1)
     p i Ps print(i+1) print i+1 i 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N=ii()

    city = []
    dic = {}
    for i in range(N):
        S,P=isp()
        P = int(P)
        if not S in city:
            city.append(S)
            dic[S] = [(P,i)]
        else:
            dic[S].append((P,i))
    
    city.sort()
    for S in city:
        Ps = dic[S]
        Ps.sort(reverse=True) 
        for p,i in Ps:
            print(i+1)
     def main():
    N=ii()

    city = []
    dic = {}
    for i in range(N):
        S,P=isp()
        P = int(P)
        if not S in city:
            city.append(S)
            dic[S] = [(P,i)]
        else:
            dic[S].append((P,i))
    
    city.sort()
    for S in city:
        Ps = dic[S]
        Ps.sort(reverse=True) 
        for p,i in Ps:
            print(i+1)
     main def mi(): return map(int,input().split()) def mi(): return map(int,input().split()) mi def ii(): return int(input()) def ii(): return int(input()) ii def isp(): return input().split() def isp(): return input().split() isp def deb(text): print("-------\n{}\n-------".format(text)) def deb(text): print("-------\n{}\n-------".format(text)) deb INF=10**20 10**20 INF
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()

    city = []
    dic = {}
    for i in range(N):
        S,P=isp()
        P = int(P)
        if not S in city:
            city.append(S)
            dic[S] = [(P,i)]
        else:
            dic[S].append((P,i))
    
    city.sort()
    for S in city:
        Ps = dic[S]
        Ps.sort(reverse=True) 
        for p,i in Ps:
            print(i+1)
    


if __name__ == "__main__":
    main()