#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<ctime>
#include<cstdio> 
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct note
{
	string s;
	int k,num;
}a[105];
bool cmp(note a,note b)
{
	if(a.s==b.s) return a.k>b.k;
	else return a.s<b.s;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i) 
	{
		cin>>a[i].s;
		cin>>a[i].k;
		a[i].num=i;
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;++i) cout<<a[i].num<<endl;
	return 0;
}