#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    restaurants=[]
    n = int(input())
    restaurants=[list(input().split()) for _ in range(n)]

    for idx,restaurant in enumerate(restaurants):
        restaurants[idx][1]=int(str(restaurant[1]))
        restaurants[idx].append(idx+1)
    restaurants.sort(key=lambda x:x[1],reverse=True)
    restaurants.sort(key=lambda x:x[0].lower())
    for restaurant in restaurants:
        print(restaurant[2])

if __name__=="__main__":
    main() import sys sys input=sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline import numpy as np numpy def main():
    restaurants=[]
    n = int(input())
    restaurants=[list(input().split()) for _ in range(n)]

    for idx,restaurant in enumerate(restaurants):
        restaurants[idx][1]=int(str(restaurant[1]))
        restaurants[idx].append(idx+1)
    restaurants.sort(key=lambda x:x[1],reverse=True)
    restaurants.sort(key=lambda x:x[0].lower())
    for restaurant in restaurants:
        print(restaurant[2]) main restaurants=[] restaurants [] n = int(input()) n int(input()) int input() input list(input().split()) for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) list(input().split()) list input().split() ().split () input split restaurants=[list(input().split()) for _ in range(n)] restaurants [list(input().split()) for _ in range(n)] for idx,restaurant in enumerate(restaurants):
        restaurants[idx][1]=int(str(restaurant[1]))
        restaurants[idx].append(idx+1)
     idx restaurant enumerate(restaurants) enumerate restaurants restaurants[idx][1]=int(str(restaurant[1])) restaurants[idx][1] [idx] restaurants idx 1 int(str(restaurant[1])) int str(restaurant[1]) str restaurant[1] restaurant 1 restaurants[idx].append(idx+1) [idx].append [idx] restaurants idx append idx+1 idx 1 restaurants.sort(key=lambda x:x[1],reverse=True) restaurants.sort restaurants sort key=lambda x:x[1] key lambda x:x[1] x[1] x 1 x reverse=True reverse True restaurants.sort(key=lambda x:x[0].lower()) restaurants.sort restaurants sort key=lambda x:x[0].lower() key lambda x:x[0].lower() x[0].lower() [0].lower [0] x 0 lower x for restaurant in restaurants:
        print(restaurant[2]) restaurant restaurants print(restaurant[2]) print restaurant[2] restaurant 2 if __name__=="__main__":
    main() __name__=="__main__" __name__ "__main__" main() main def main():
    restaurants=[]
    n = int(input())
    restaurants=[list(input().split()) for _ in range(n)]

    for idx,restaurant in enumerate(restaurants):
        restaurants[idx][1]=int(str(restaurant[1]))
        restaurants[idx].append(idx+1)
    restaurants.sort(key=lambda x:x[1],reverse=True)
    restaurants.sort(key=lambda x:x[0].lower())
    for restaurant in restaurants:
        print(restaurant[2]) def main():
    restaurants=[]
    n = int(input())
    restaurants=[list(input().split()) for _ in range(n)]

    for idx,restaurant in enumerate(restaurants):
        restaurants[idx][1]=int(str(restaurant[1]))
        restaurants[idx].append(idx+1)
    restaurants.sort(key=lambda x:x[1],reverse=True)
    restaurants.sort(key=lambda x:x[0].lower())
    for restaurant in restaurants:
        print(restaurant[2]) main input=sys.stdin.readline sys.stdin.readline input
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import numpy as np

def main():
    restaurants=[]
    n = int(input())
    restaurants=[list(input().split()) for _ in range(n)]

    for idx,restaurant in enumerate(restaurants):
        restaurants[idx][1]=int(str(restaurant[1]))
        restaurants[idx].append(idx+1)
    restaurants.sort(key=lambda x:x[1],reverse=True)
    restaurants.sort(key=lambda x:x[0].lower())
    for restaurant in restaurants:
        print(restaurant[2])

if __name__=="__main__":
    main()