#include <bits/stdc++.h>

using namespace std;

int main(void){
	int N;
	cin >> N;
	vector<tuple<string,int,int>> a;
	for(int i=0;i<N;i++){
		string S;
		int p;
		cin >> S >> p;
		p = -p;
		a.push_back(tie(S,p,i));
	}
	sort(a.begin(),a.end());
	for(int i=0;i<N;i++){
		cout << get<2>(a[i])+1 << endl;
	}
}