#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair<ll, ll>;
using vec = vector<ll>;
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll a;
  cin >> a;
  vector<tuple<string, ll, ll>> q;
  string s;
  ll a1;
  for (ll i = 0; i < a; i++) {
    cin >> s >> a1;
    q.push_back(make_tuple(s, -a1, i + 1));
  }
  sort(q.begin(), q.end());
  for (ll i = 0; i < a; i++) {
    cout << get<2>(q[i]) << "\n";
  }
  return 0;
}
