import std.stdio;
import std.string;
import std.conv;
import std.algorithm;

struct Restaurant {
  string city;
  int point;
  int index;
};

static bool greaterR(Restaurant a, Restaurant b) {
  bool f = true;
  if (a.city > b.city) {
    f = false;
  } else if (a.city == b.city) {
    f = a.point > b.point;
  }

  return f;
}

void main() {
  int n = readln.chomp.to!(int);
  Restaurant[] restaurants;

  for (int i = 0; i < n; i++) {
    string[] buf = readln.chomp.split;
    restaurants ~= Restaurant(buf[0], buf[1].to!(int), i + 1);
  }

  sort!(greaterR)(restaurants);

  foreach (e; restaurants) {
    e.index.writeln;
  }
}
