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

int main() {
  int N;
  cin >> N;
  vector<tuple<string,int,int>> t;
  
  for(int i=0;i<N;i++){
    string s;
    int a;
    cin >> s >> a;
    t.push_back(make_tuple(s,-1*a,i+1));
  }

  sort(t.begin(),t.end());

  for(int i=0;i<N;i++){
    cout << get<2>(t.at(i)) << endl;
  }
}