'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const n = parseInt(args[0][0], 10)

	const items = args.slice(1, n + 1).map((arg, index) => [arg[0], arg[1], index + 1]).sort((a, b) => {
		const t1 = parseInt(a[1], 10)
		const t2 = parseInt(b[1], 10)

		if (a[0] < b[0]) return -1
		else if (a[0] > b[0]) return 1
		else if (t1 > t2) return -1
		else if (t1 < t2) return 1
		return 0
	})

	for (let i = 0; i < items.length; i++) {
		console.log(items[i][2])
	}
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
