#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll mod = 1000000007;
ll INF = 1000000099;
signed main() {
  ll n;
  cin >> n;
  vector<pair<pair<string, int>, int>> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i).first.first >> v.at(i).first.second;
    v.at(i).first.second *= (-1);
    v.at(i).second = i + 1;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    cout << v.at(i).second << endl;
  }
}
