((stdin) => {
  var lines = stdin.trim().split('\n');
  var n = Number(lines.shift());
  var ratings = lines.map(function(val, index) {
    var vals = val.split(' ');
    return [index, vals[0], Number(vals[1])];
  });
  ratings.sort(function(a, b) {
    if (a[1] === b[1]) {
      return b[2] - a[2];
    } else if (a[1] > b[1]) {
      return 1;
    } else {
      return -1;
    }
  });
  console.log(ratings.map(function(val) { return val[0] + 1; }).join('\n'));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));