#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  cin>>N;
  vector<tuple<string,int,int>>p;
  for(int i=0;i<N;i++){
    string s;
    int a;
    cin>>s>>a;
    p.push_back(make_tuple(s, a*(-1), i+1));
  }
  sort(p.begin(), p.end());
  for(int i=0;i<N;i++){
    cout<<get<2>(p.at(i))<<endl;
  }
}