#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
template <class T, class C>
void chmax(T& a, C b) {
  a > b ?: a = b;
}
template <class T, class C>
void chmin(T& a, C b) {
  a < b ?: a = b;
}
int main(int argc, char* argv[]) {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> p(n);
  map<string, int> res;
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> p[i];
    s[i] = s[i] + std::to_string(100 - p[i]);
    res[s[i]] = i + 1;
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) cout << res[s[i]] << endl;
  return 0;
}
