#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  pair<pair<string, int>, int> books[n];
  string s;
  int p;
  for (int i = 0; i < (int)(n); i++) {
    cin >> s >> p;
    books[i] = make_pair(make_pair(s, -p), i);
  }
  sort(books, books + n);
  for (int i = 0; i < (int)(n); i++) cout << (books[i].second) + 1 << endl;
}
