"use strict";
function Main(input) {
  const args = input.split('\n');
  const N = parseInt(args.shift());
  const SP = args
  .filter((f, i) => i < N)
  .map((m1, i) => {
    const ms = m1.split(' ');
    return {
      S: ms[0],
      P: parseInt(ms[1]),
      i: i + 1
    };
  })
  .sort((a ,b) => {
    const cS = b.S.localeCompare(a.S);
    if (b.S !== a.S) {
      return b.S < a.S ? 1 : -1;
    }
    return b.P - a.P;
  }).forEach((f) => {
    console.log(f.i);
  });
}

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