function Main(input) {
  const lines = input.split("\n").slice(1).map((line, i) => {
    const [S, P] = line.split(' ');
    return { name: S, score: P, id: i + 1 };
  });
  lines.sort((a, b) => {
    if (a.name > b.name) {
      return 1;
    }
    else if (a.name < b.name) {
      return -1;
    }
    else {
      return b.score - a.score;
    }
  });
  lines.forEach(line => {
    console.log(line.id.toString());
  });
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));