#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc128_b

N = int(input())
numbers = []
cities = []
points = []

for i in range(N):
    city, point = input().split()
    numbers.append(i+1)
    cities.append(city)
    points.append(int(point))

def switch_order(l, i, j):
    tmp = l[i]
    l[i] = l[j]
    l[j] = tmp

for i in range(N):
    for j in range(i):
        if cities[j] < cities[i]:
            continue
        if cities[j] > cities[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)
        if cities[j] == cities[i] and points[j] < points[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)

for i in range(N):
    print(numbers[i]) N = int(input()) N int(input()) int input() input numbers = [] numbers [] cities = [] cities [] points = [] points [] for i in range(N):
    city, point = input().split()
    numbers.append(i+1)
    cities.append(city)
    points.append(int(point)) i range(N) range N city, point = input().split() city input().split() ().split () input split point numbers.append(i+1) numbers.append numbers append i+1 i 1 cities.append(city) cities.append cities append city points.append(int(point)) points.append points append int(point) int point def switch_order(l, i, j):
    tmp = l[i]
    l[i] = l[j]
    l[j] = tmp switch_order tmp = l[i] tmp l[i] l i l[i] = l[j] l[i] l i l[j] l j l[j] = tmp l[j] l j tmp l l i i j j for i in range(N):
    for j in range(i):
        if cities[j] < cities[i]:
            continue
        if cities[j] > cities[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)
        if cities[j] == cities[i] and points[j] < points[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j) i range(N) range N for j in range(i):
        if cities[j] < cities[i]:
            continue
        if cities[j] > cities[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)
        if cities[j] == cities[i] and points[j] < points[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j) j range(i) range i if cities[j] < cities[i]:
            continue
         cities[j] < cities[i] cities[j] cities j cities[i] cities i continue if cities[j] > cities[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)
         cities[j] > cities[i] cities[j] cities j cities[i] cities i switch_order(numbers, i, j) switch_order numbers i j switch_order(cities, i, j) switch_order cities i j switch_order(points, i, j) switch_order points i j if cities[j] == cities[i] and points[j] < points[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j) cities[j] == cities[i] and points[j] < points[i] cities[j] == cities[i] cities[j] cities j cities[i] cities i points[j] < points[i] points[j] points j points[i] points i switch_order(numbers, i, j) switch_order numbers i j switch_order(cities, i, j) switch_order cities i j switch_order(points, i, j) switch_order points i j for i in range(N):
    print(numbers[i]) i range(N) range N print(numbers[i]) print numbers[i] numbers i numbers = [] [] numbers N = int(input()) int(input()) N cities = [] [] cities point = input().split() input().split() point points = [] [] points def switch_order(l, i, j):
    tmp = l[i]
    l[i] = l[j]
    l[j] = tmp def switch_order(l, i, j):
    tmp = l[i]
    l[i] = l[j]
    l[j] = tmp switch_order city, point = input().split() input().split() city
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc128_b

N = int(input())
numbers = []
cities = []
points = []

for i in range(N):
    city, point = input().split()
    numbers.append(i+1)
    cities.append(city)
    points.append(int(point))

def switch_order(l, i, j):
    tmp = l[i]
    l[i] = l[j]
    l[j] = tmp

for i in range(N):
    for j in range(i):
        if cities[j] < cities[i]:
            continue
        if cities[j] > cities[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)
        if cities[j] == cities[i] and points[j] < points[i]:
            switch_order(numbers, i, j)
            switch_order(cities, i, j)
            switch_order(points, i, j)

for i in range(N):
    print(numbers[i])
