#include <bits/stdc++.h>
using namespace std;
struct sp {
  long long idx, p;
  string s;
  bool operator<(const sp& another) const {
    if (s != another.s) return s < another.s;
    return p > another.p;
  }
};
signed main() {
  long long n;
  cin >> n;
  vector<sp> vec(n);
  for (long long i = 0; i < n; i++) {
    vec[i].idx = i + 1;
    cin >> vec[i].s >> vec[i].p;
  }
  sort(vec.begin(), vec.end());
  for (long long i = 0; i < n; i++) {
    cout << vec[i].idx << endl;
  }
  return 0;
}
