#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(int argc, char const* argv[]) {
  int n, p;
  string s;
  vector<tuple<string, int, int>> v;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s >> p;
    v.push_back(make_tuple(s, -p, i + 1));
  }
  sort(v.begin(), v.end());
  for (auto p : v) {
    cout << get<2>(p) << endl;
  }
  return 0;
}
