#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  vector<string> cities;
  vector<int> values;
  vector<int> ids;
  for (int i = 0; i < a; ++i) {
    string b;
    int c;
    cin >> b;
    cin >> c;
    cities.push_back(b);
    values.push_back(c);
    ids.push_back(i);
  }
  for (int i = 0; i < a; ++i) {
    for (int j = i; j < a; ++j) {
      if (cities[i] > cities[j]) {
        string temp = cities[i];
        cities[i] = cities[j];
        cities[j] = temp;
        int v = values[i];
        values[i] = values[j];
        values[j] = v;
        int e = ids[i];
        ids[i] = ids[j];
        ids[j] = e;
      } else if (cities[i] == cities[j]) {
        if (values[i] < values[j]) {
          string temp = cities[i];
          cities[i] = cities[j];
          cities[j] = temp;
          int v = values[i];
          values[i] = values[j];
          values[j] = v;
          int e = ids[i];
          ids[i] = ids[j];
          ids[j] = e;
        }
      }
    }
  }
  for (int i = 0; i < a; ++i) {
    cout << ids[i] + 1 << endl;
  }
  return 0;
}
