function main(input) {
  var args = input.split('\n');
  var n = Number(args[0]);
  var list = [];
  for(var i = 1; i <= n; i++) {
    var values = args[i].split(' ');
    list.push({
      s: values[0],
      p: Number(values[1]),
      n: i
    });
  }

  var newList = [];

  function comp(a, b) {
    if(a.s === b.s) {
      return a.p < b.p;
    }
    else {
      return a.s > b.s;
    }
  }

  list.sort(comp);

  //console.dir(list);
  for(var v of list) {
    console.log(v.n);
  }

}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
