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

typedef pair<string,int> p;
int n;

int main(void){
    string x;
    int y;
    cin >> n;
    map<p,int> sp;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        sp[p(x,y*-1)] = i+1;
    }
    for(pair<p,int> itr: sp){
        cout << itr.second << endl;
    }
}

