import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    N =int(input())
    l=[]
    for i in range(N):
        k,s = input().split()
        s = int(s)
        l.append([k,s,i+1])



    l.sort(reverse=True)
    mem =""
    q=[]
    for i in range(N):
        k,s,j = l.pop()
        if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
    q.sort(reverse=True)
    if q:
        for o, p in q:
            print(p)






if __name__ == "__main__":
    main() import sys sys from collections import deque def input():
    return sys.stdin.readline().rstrip() input return sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def main():
    N =int(input())
    l=[]
    for i in range(N):
        k,s = input().split()
        s = int(s)
        l.append([k,s,i+1])



    l.sort(reverse=True)
    mem =""
    q=[]
    for i in range(N):
        k,s,j = l.pop()
        if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
    q.sort(reverse=True)
    if q:
        for o, p in q:
            print(p) main N =int(input()) N int(input()) int input() input l=[] l [] for i in range(N):
        k,s = input().split()
        s = int(s)
        l.append([k,s,i+1])



     i range(N) range N k,s = input().split() k input().split() ().split () input split s s = int(s) s int(s) int s l.append([k,s,i+1]) l.append l append [k,s,i+1] k s i+1 i 1 l.sort(reverse=True) l.sort l sort reverse=True reverse True mem ="" mem "" q=[] q [] for i in range(N):
        k,s,j = l.pop()
        if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
     i range(N) range N k,s,j = l.pop() k l.pop() l.pop l pop s j if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
     mem ==k mem k q.append([s,j]) q.append q append [s,j] s j mem =k mem k q.sort(reverse=True) q.sort q sort reverse=True reverse True for o,p in q:
                print(p)
             o p q print(p) print p q=[] q [] q.append([s, j]) q.append q append [s, j] s j mem =k mem k q.sort(reverse=True) q.sort q sort reverse=True reverse True if q:
        for o, p in q:
            print(p) q for o, p in q:
            print(p) o p q print(p) print p if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    N =int(input())
    l=[]
    for i in range(N):
        k,s = input().split()
        s = int(s)
        l.append([k,s,i+1])



    l.sort(reverse=True)
    mem =""
    q=[]
    for i in range(N):
        k,s,j = l.pop()
        if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
    q.sort(reverse=True)
    if q:
        for o, p in q:
            print(p) def main():
    N =int(input())
    l=[]
    for i in range(N):
        k,s = input().split()
        s = int(s)
        l.append([k,s,i+1])



    l.sort(reverse=True)
    mem =""
    q=[]
    for i in range(N):
        k,s,j = l.pop()
        if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
    q.sort(reverse=True)
    if q:
        for o, p in q:
            print(p) main def input():
    return sys.stdin.readline().rstrip() def input():
    return sys.stdin.readline().rstrip() input
import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    N =int(input())
    l=[]
    for i in range(N):
        k,s = input().split()
        s = int(s)
        l.append([k,s,i+1])



    l.sort(reverse=True)
    mem =""
    q=[]
    for i in range(N):
        k,s,j = l.pop()
        if mem ==k:
            q.append([s,j])
            mem =k
        else:
            q.sort(reverse=True)
            for o,p in q:
                print(p)
            q=[]
            q.append([s, j])
            mem =k
    q.sort(reverse=True)
    if q:
        for o, p in q:
            print(p)






if __name__ == "__main__":
    main()
