import java.lang.Math
import kotlin.comparisons.*

val MOD: Int = 1000000000 + 7
val MODL: Long = MOD.toLong()

data class Restaurant(val no: Int, val city: String, val score: Int)

fun main(args: Array<String>)
{
    val n = read().toInt()
    val list = mutableListOf<Restaurant>()
    for (i in 1..n) {
        val (s, p) = read().split()
        list.add(Restaurant(i, s, p.toInt()))
    }
    list.sortWith(compareBy({it.city}, {-it.score}))

    for (i in 0 until n) {
        println(list[i].no)
    }
}

fun read(): String = readLine()!!
fun CharSequence.split(): List<String> = this.split(" ")
fun Iterable<String>.toInt(): List<Int> = this.map{it.toInt()}
