#include <bits/stdc++.h>
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using ll = long long;
vector<pair<string, int>> p(100);
int order[100];
void allSwap(int a) {
  swap(p[a].first, p[a + 1].first);
  swap(p[a].second, p[a + 1].second);
  swap(order[a], order[a + 1]);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < (int)(n); i++) {
    string s;
    int a;
    cin >> s >> a;
    p[i].first = s;
    p[i].second = a;
    order[i] = i + 1;
  }
  int j = n - 1;
  while (j > 0) {
    for (int i = 0; i < (int)(j); i++) {
      if (p[i].first > p[i + 1].first) {
        allSwap(i);
      } else if (p[i].first == p[i + 1].first &&
                 p[i].second < p[i + 1].second) {
        allSwap(i);
      }
    }
    j--;
  }
  for (int i = 0; i < (int)(n); i++) {
    cout << order[i] << endl;
  }
}
