#include<bits/stdc++.h>
using namespace std;
int main() {
  int n,i;
  cin>>n;
  vector<tuple<string,int,int>> t(n);
  for(i=0;i<n;i++) {
    cin>>get<0>(t.at(i))>>get<1>(t.at(i));
    get<1>(t.at(i))=-get<1>(t.at(i));
    get<2>(t.at(i))=i;
  }
  sort(t.begin(),t.end());
  for(i=0;i<n;i++) cout<<get<2>(t.at(i))+1<<endl;
}