#include <bits/stdc++.h>
using namespace std;
int main() {
  pair<pair<string, int>, int> m[110];
  int a;
  cin >> a;
  for (int i = 0; i < a; i++) {
    int t;
    string city;
    cin >> city >> t;
    m[i] = make_pair(make_pair(city, t), i);
  }
  sort(m, m + a);
  for (int i = 0; i < a; i++) {
    cout << m[i].second + 1 << endl;
  }
}
