#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n;
struct node{
	char s[11];
	int p;
	int id;
}a[110];
bool cmp(node u,node v){
	int w=strcmp(u.s,v.s);
	if(w!=0){
		return w<0;
	}
	return u.p>v.p;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%s%d",a[i].s,&a[i].p);
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++)printf("%d\n",a[i].id);
	return 0;
}