#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	pair<pair<string, int>, int> v[100];
	string s;
	int t;
	for (int i = 0; i < n; i++) {
		cin >> s >> t;
		v[i] = make_pair(make_pair(s, -t), i + 1);
	}
	sort(v, v + n);
	for (int i = 0; i < n; i++)
		cout << v[i].second << endl;
	return 0;
}
