def main():
    n = int(input())
    inlis = []
    namelis = []
    for i in range(n):
        a, b = map(str, input().split())
        b = int(b)
        inlis.append([a,b])
        namelis.append(a)
    namelis.sort()    
    inlis_so = sorted(inlis)
    anslis = []
    for num in inlis:
        #print(num, num[0], inlis_so, inlis_so.count(num[0]))
        kazu = namelis.count(num[0])
        if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
    for i in range(1, n+1):
        #print(anslis)
        print(anslis.index(i)+1)

    

        
    
if __name__ == "__main__":
    main() def main():
    n = int(input())
    inlis = []
    namelis = []
    for i in range(n):
        a, b = map(str, input().split())
        b = int(b)
        inlis.append([a,b])
        namelis.append(a)
    namelis.sort()    
    inlis_so = sorted(inlis)
    anslis = []
    for num in inlis:
        #print(num, num[0], inlis_so, inlis_so.count(num[0]))
        kazu = namelis.count(num[0])
        if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
    for i in range(1, n+1):
        #print(anslis)
        print(anslis.index(i)+1)

    

        
     main n = int(input()) n int(input()) int input() input inlis = [] inlis [] namelis = [] namelis [] for i in range(n):
        a, b = map(str, input().split())
        b = int(b)
        inlis.append([a,b])
        namelis.append(a)
     i range(n) range n a, b = map(str, input().split()) a map(str, input().split()) map str input().split() ().split () input split b b = int(b) b int(b) int b inlis.append([a,b]) inlis.append inlis append [a,b] a b namelis.append(a) namelis.append namelis append a namelis.sort() namelis.sort namelis sort inlis_so = sorted(inlis) inlis_so sorted(inlis) sorted inlis anslis = [] anslis [] for num in inlis:
        #print(num, num[0], inlis_so, inlis_so.count(num[0]))
        kazu = namelis.count(num[0])
        if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
     num inlis kazu = namelis.count(num[0]) kazu namelis.count(num[0]) namelis.count namelis count num[0] num 0 if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
     kazu == 1 kazu 1 anslis.append(inlis_so.index(num)+1) anslis.append anslis append inlis_so.index(num)+1 inlis_so.index(num) inlis_so.index inlis_so index num 1 kijun = namelis.index(num[0]) + 1 kijun namelis.index(num[0]) + 1 namelis.index(num[0]) namelis.index namelis index num[0] num 0 1 kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis)) kouho list(filter(lambda word:True if word[0] == num[0] else False,inlis)) list filter(lambda word:True if word[0] == num[0] else False,inlis) filter lambda word:True if word[0] == num[0] else False True if word[0] == num[0] else False word[0] == num[0] word[0] word 0 num[0] num 0 True False word inlis kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True) kouho_so sorted(kouho, key = lambda x:x[1], reverse = True) sorted kouho key = lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse = True reverse True suujibun = kouho_so.index(num) suujibun kouho_so.index(num) kouho_so.index kouho_so index num anslis.append(kijun + suujibun) anslis.append anslis append kijun + suujibun kijun suujibun for i in range(1, n+1):
        #print(anslis)
        print(anslis.index(i)+1)

    

        
     i range(1, n+1) range 1 n+1 n 1 print(anslis.index(i)+1) print anslis.index(i)+1 anslis.index(i) anslis.index anslis index i 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = int(input())
    inlis = []
    namelis = []
    for i in range(n):
        a, b = map(str, input().split())
        b = int(b)
        inlis.append([a,b])
        namelis.append(a)
    namelis.sort()    
    inlis_so = sorted(inlis)
    anslis = []
    for num in inlis:
        #print(num, num[0], inlis_so, inlis_so.count(num[0]))
        kazu = namelis.count(num[0])
        if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
    for i in range(1, n+1):
        #print(anslis)
        print(anslis.index(i)+1)

    

        
     def main():
    n = int(input())
    inlis = []
    namelis = []
    for i in range(n):
        a, b = map(str, input().split())
        b = int(b)
        inlis.append([a,b])
        namelis.append(a)
    namelis.sort()    
    inlis_so = sorted(inlis)
    anslis = []
    for num in inlis:
        #print(num, num[0], inlis_so, inlis_so.count(num[0]))
        kazu = namelis.count(num[0])
        if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
    for i in range(1, n+1):
        #print(anslis)
        print(anslis.index(i)+1)

    

        
     main
def main():
    n = int(input())
    inlis = []
    namelis = []
    for i in range(n):
        a, b = map(str, input().split())
        b = int(b)
        inlis.append([a,b])
        namelis.append(a)
    namelis.sort()    
    inlis_so = sorted(inlis)
    anslis = []
    for num in inlis:
        #print(num, num[0], inlis_so, inlis_so.count(num[0]))
        kazu = namelis.count(num[0])
        if kazu == 1:
            anslis.append(inlis_so.index(num)+1)
        else:
            kijun = namelis.index(num[0]) + 1
            kouho = list(filter(lambda word:True if word[0] == num[0] else False,inlis))
            kouho_so = sorted(kouho, key = lambda x:x[1], reverse = True)
            suujibun = kouho_so.index(num)
            anslis.append(kijun + suujibun)
    for i in range(1, n+1):
        #print(anslis)
        print(anslis.index(i)+1)

    

        
    
if __name__ == "__main__":
    main()
