struct Restaurant {
  let index: Int
  let city: String
  let point: Int
}

var table: [String: [Restaurant]] = [:]

let N = Int(readLine()!)!

for i in 1...N {
  let inp = readLine()!.split(separator: " ").map { String($0) }
  table[inp[0], default: []].append(Restaurant(index: i, city: inp[0], point: Int(inp[1])!))
}
for key in table.keys.sorted() {
  for r in table[key]!.sorted { $0.point > $1.point } {
    print(r.index)
  }
}