#! env/bin/local python3
# -*- coding: utf-8 -*-

n = int(input())

restaurants = {}
for i in range(1, n + 1):
    info = input().split()
    restaurants[i] = {
        # 'name': info[0] + str(100 - int(info[1]))
        'name': info[0],
        'score': int(info[1])
    }

# {1: hoge} -> ([1, hoge])
results = sorted(restaurants.items(), key=lambda x: (x[1]['name'], 100 - x[1]['score']))
output = [r[0] for r in results]
print(*output, sep='\n') n = int(input()) n int(input()) int input() input restaurants = {} restaurants {} for i in range(1, n + 1):
    info = input().split()
    restaurants[i] = {
        # 'name': info[0] + str(100 - int(info[1]))
        'name': info[0],
        'score': int(info[1])
    }

# {1: hoge} -> ([1, hoge]) i range(1, n + 1) range 1 n + 1 n 1 info = input().split() info input().split() ().split () input split restaurants[i] = {
        # 'name': info[0] + str(100 - int(info[1]))
        'name': info[0],
        'score': int(info[1])
    } restaurants[i] restaurants i {
        # 'name': info[0] + str(100 - int(info[1]))
        'name': info[0],
        'score': int(info[1])
    } 'name' 'name' info[0] info 0 'score' 'score' int(info[1]) int info[1] info 1 results = sorted(restaurants.items(), key=lambda x: (x[1]['name'], 100 - x[1]['score'])) results sorted(restaurants.items(), key=lambda x: (x[1]['name'], 100 - x[1]['score'])) sorted restaurants.items() restaurants.items restaurants items key=lambda x: (x[1]['name'], 100 - x[1]['score']) key lambda x: (x[1]['name'], 100 - x[1]['score']) (x[1]['name'], 100 - x[1]['score']) x[1]['name'] [1] x 1 'name' 100 - x[1]['score'] 100 x[1]['score'] [1] x 1 'score' x r[0] for r in results for r in results r results for r in results r[0] r 0 output = [r[0] for r in results] output [r[0] for r in results] print(*output, sep='\n') print *output output sep='\n' sep '\n' restaurants = {} {} restaurants info = input().split() input().split() info n = int(input()) int(input()) n output = [r[0] for r in results] [r[0] for r in results] output results = sorted(restaurants.items(), key=lambda x: (x[1]['name'], 100 - x[1]['score'])) sorted(restaurants.items(), key=lambda x: (x[1]['name'], 100 - x[1]['score'])) results
#! env/bin/local python3
# -*- coding: utf-8 -*-

n = int(input())

restaurants = {}
for i in range(1, n + 1):
    info = input().split()
    restaurants[i] = {
        # 'name': info[0] + str(100 - int(info[1]))
        'name': info[0],
        'score': int(info[1])
    }

# {1: hoge} -> ([1, hoge])
results = sorted(restaurants.items(), key=lambda x: (x[1]['name'], 100 - x[1]['score']))
output = [r[0] for r in results]
print(*output, sep='\n')
