#include<bits/stdc++.h>
using namespace std;
int main()
{
	pair<pair<string,int>,int> p[120];
	int n;
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		string s;
		cin>>s;
		int m;
		cin>>m;
		p[i] = make_pair(make_pair(s,-m),i+1);
	}
	sort(p,p+n);
	for (int i = 0; i < n; ++i)
	{
		cout<<p[i].second<<endl;
	}
}