"use strict"

function Main(input) {
  let dataList = input.split("\n");
  dataList.shift();
  dataList.pop();
  let restaurants = dataList.map((data, index) => {
    const tmp = data.split(" ")
    return { index: index + 1, city: tmp[0], score: parseInt(tmp[1]) }
  });
  restaurants.sort(function(a, b) {
    if (a.city < b.city) return -1
    if (a.city > b.city) return 1
    if (a.score < b.score) return 1
    if (a.score > b.score) return -1
  });
  restaurants.forEach(restaurant => {
    console.log(restaurant.index);
  });
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
