#include <bits/stdc++.h>
using namespace std;
 
int main() {

	int N;
	cin >> N;
	vector<tuple <string,int,int>> R(N);
	for (int i=0; i<N; i++){
		string S;
		int P;
		cin >> S >> P;
		R.at(i) = make_tuple(S,100-P,i+1);
	}
	
	sort(R.begin(),R.end());
	for (int i=0; i<N; i++){
		cout << get<2>(R.at(i)) << endl;
	}
}
