#include <bits/stdc++.h>
using namespace std;
template <typename T>
T mod(T a, T b) {
  return (a + b) % b;
}
template <typename T>
T gcd(T a, T b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
map<long long, long long> factor(long long n) {
  map<long long, long long> mp;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      mp[i]++;
      n /= i;
    }
  }
  if (n > 1) {
    mp[n]++;
  }
  return mp;
}
void solve() {
  int N;
  cin >> N;
  vector<string> city;
  vector<int> point;
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    city.push_back(s);
    point.push_back(p);
  }
  map<pair<string, int>, int> mp;
  for (int i = 0; i < N; i++) {
    mp[make_pair(city[i], point[i])] = i + 1;
  }
  map<string, vector<int>> m;
  for (int i = 0; i < N; i++) {
    m[city[i]].push_back(point[i]);
  }
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    sort((itr->second).begin(), (itr->second).end());
    reverse((itr->second).begin(), (itr->second).end());
  }
  for (auto itr = m.begin(); itr != m.end(); itr++) {
    for (int k = 0; k < (itr->second).size(); k++)
      cout << mp[make_pair(itr->first, (itr->second)[k])] << endl;
  }
  return;
}
int main(int argc, char const* argv[]) {
  solve();
  return 0;
}
