'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let N = input[0].split(' ').map(Number)[0];
  // let Arr1 = input[1].split(' ').map(Number);
  let Res = [];

  // 連想配列(Dictionary)に格納
  for (let i = 1; i <= N; i++) {
    Res[i - 1] = {
      souceOrder: i,
      city: input[i].split(' ')[0],
      score: parseInt(input[i].split(' ')[1]),
      printOrder: 1
    }
  }

  // city昇順 score降順 の順に並べ替え
  Res.sort((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;
    return 0;
  });

  for (let i = 0; i < N; i++) {
    Res[i].printOrder = (i + 1);
  }
  // souceOrder昇順に並べ替え
  Res.sort((a, b) => {
    if (a.souceOrder < b.souceOrder) return -1;
    if (a.souceOrder > b.souceOrder) return 1;
    return 0;
  });

  let Ans = [];
  for (let i = 0; i < N; i++) {
    Ans.push(Res[i].printOrder);
  }

  console.log(Ans.join('\n'));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
