#include <bits/stdc++.h>
using namespace std;
bool comparion(pair<string, long long int> a, pair<string, long long int> b) {
  if (a.first == b.first) return (a.second > b.second);
  return (a.first < b.first);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n;
  cin >> n;
  pair<string, long long int> p[n];
  long long int a[100] = {0};
  for (long long int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
    a[p[i].second] = i + 1;
  }
  sort(p, p + n, comparion);
  for (long long int i = 0; i < n; i++) {
    cout << a[p[i].second] << '\n';
  }
}
