#include"bits/stdc++.h"
#include"math.h"
using namespace std;

int main(){
  int n; cin >> n;
  vector<tuple<string , int , int>> S;
  for(int i=0; i<n; i++){
    string s; int p;
     cin >> s >> p;
    S.push_back(make_tuple(s , 100-p , i+1));}
  sort(S.begin(),S.end());
  
  for(auto x:S)
  {cout << get<2>(x) << endl;}
    
}