import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val a = IntArray(n)
    val s = mutableListOf<String>()
    val p = IntArray(n)
    for (i in 0 until n) {
        a[i] = i
        val t = scanner.next()
        s.add(t)
        p[i] = scanner.nextInt()
    }
    for (i in 0 until n) {
        for (l in 0 until n - 1) {
            if (s[l] > s[l + 1]) {
                val ss = s[l]
                s[l] = s[l + 1]
                s[l + 1] = ss
                val b = a[l]
                a[l] = a[l + 1]
                a[l + 1] = b
                val q = p[l]
                p[l] = p[l + 1]
                p[l + 1] = q
            }
        }
    }
    for (i in 0 until n) {
        for (l in 0 until n - 1) {
            if (s[l] == s[l + 1]) {
                if (p[l] < p[l + 1]) {
                    val b = a[l]
                    a[l] = a[l + 1]
                    a[l + 1] = b
                    val q = p[l]
                    p[l] = p[l + 1]
                    p[l + 1] = q
                }
            }
        }
    }
    for (i in 0 until n) {
        println(a[i] + 1)
    }
}
