#include<iostream>
#include<algorithm>
#include<string>
using namespace std;

class Obj{
  private:
  	string name;
  	int sort;
  public:
  	void set_name(string n){
      name = n;
    };
  	string get_name(){
      return name;
    };
  	void set_sort(int i){
      sort = i;
    };
  	int get_sort(){
      return sort;
    };
}

int main(){
  int n;
  cin >> n;
  string s[n], p[n];
  Obj o[n];
  for(int i = 0; i < n; i++){
    cin >> s[i] >> p[i];
    s[i] = s[i] + " -" + p[i];
    o[i].set_name(s[i]);
    o[i].set_sort(i+1);
  }
  sort(o[0].name, o[n-1].name);
  for(int i = 0; i < n; i++){
    cout << o[i].get_sort << endl;
  }
  return 0;
}  
  
