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

int main(){
	int n;
	scanf("%d", &n);
	vector< tuple<string, int, int> > t(n);
	for(int i=0; i < n; i++) {
		cin >> get<0>(t.at(i)) >> get<1>(t.at(i));
		get<1>(t.at(i)) *= -1;;
		get<2>(t.at(i)) = i+1;
	}
	sort(t.begin(), t.end());
	for(auto &tx : t) {
		printf("%d\n", get<2>(tx));
	}
}
