"use strict";

// read lines from stdin
const input = require("fs")
  .readFileSync("/dev/stdin", "utf8")
  .split("\n");

const N = parseInt(input[0], 10);

const stores = [];

for (let i = 1; i <= N; i++) {
  const line = input[i].split(" ");
  stores.push({
    index: i,
    city: line[0],
    point: parseInt(line[1], 10),
  });
}

stores.sort((a, b) => {
  if (a.city !== b.city) {
    return a.city > b.city;
  }

  return b.point - a.point;
}).forEach((v) => console.log(v.index));
