#include<bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

*/
#define MAX 10000001
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<cassert>
//#include<unordered_map>
#define ll long long
#define ld long double
#define lli long long int
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
//#define mp make_pair
#define loop(i,n) for (lli i = 0; i < n; i++)
#define FOR(i,a,b) for (lli i = a; i < b; i+=1)
#define loop_rev(i,n) for (lli i = n-1; i >= 0; i--)
#define FOR_REV(i,a,b) for (lli i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define F first
#define S second
#define mii map<lli,lli>
#define vi vector<lli>
#define vvi vector<lli>
#define itr :: iterator it
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define abs(x) ((x < 0)?-(x):x)
#define print(x) printf("%lli\n",x);
#define print2(x,y) printf("%lli %lli\n",x,y);
#define print3(x,y,z) printf("%lli %lli %lli\n",x,y,z);
#define scan(x) scanf("%lli",&x);
#define scan2(x,y) scanf("%lli %lli",&x,&y);
#define scan3(x,y,z) scanf("%lli %lli %lli",&x,&y,&z);
#define printarr(a,n) for(lli i=0;i<n;i++)   cout<<a[i]<<" ";    cout<<"\n";
#define scanarr(a,n) for(lli i=0;i<n;i++)    scan(a[i]);
// cout<<fixed<<setprecision(6)<<value;
using namespace std;

lli find_mod(string s){
lli i,x=0;
for(i=0;i<s.length();i++)
    x=(x*10+s[i]-'0')%MOD;
return x;
}

lli prime[MAX+1];

void sieve1(){ //prime or not
    for(int i=0;i<=MAX;i++) prime[i]=1;
    prime[0]=prime[1]=0;
    for (int p=2; p*p<=MAX; p++){
        if (prime[p] == 1)
            for (int i=p*p; i<=MAX; i += p){
                prime[i] = 0;


}}}

int min_prime_div_of_n[MAX+1];

void sieve2(){ //smallest prime factor which divide a no.
memset(min_prime_div_of_n, 0, sizeof(min_prime_div_of_n));
	min_prime_div_of_n[0] = min_prime_div_of_n[1] = 1;
	for (int i = 2; i * i <= MAX; i++) {
		if (min_prime_div_of_n[i] == 0) {
			for (int j = i * 2; j < MAX; j += i) {
				if (min_prime_div_of_n[j] == 0){
					min_prime_div_of_n[j] = i;
					//cout<<min_prime_div_of_n[i]<<" ";}
			}
		}
	}
}
	for (int i = 2; i <=MAX; i++)
		if (min_prime_div_of_n[i] == 0)
			min_prime_div_of_n[i] = i;
		// If the number is prime then it's // smallest prime factor is the number // itself
}

int max_prime_div_of_n[MAX+1];

void sieve3(){ //maximum prime factor which divide a no.
    sieve1();
    memset(max_prime_div_of_n, 0, sizeof(max_prime_div_of_n));   //0 stands for is prme or not
	max_prime_div_of_n[0] = max_prime_div_of_n[1] = 1;
	for (int i = 2; i * i <= MAX; i++) {
		if (max_prime_div_of_n[i] == 0) {
			for (int j = i * 2; j < MAX; j += i) {
				if (max_prime_div_of_n[j] == 0 || ((j%i)==0 && prime[i]==1) ){
					max_prime_div_of_n[j] = i;
                    }
			}
		}
	}
	for (int i = 2; i <=MAX; i++)
		if (max_prime_div_of_n[i] == 0)//{
			max_prime_div_of_n[i] = i;
			//cout<<max_prime_div_of_n[i]<<" ";}
		// If the number is prime then it's largest prime factor is the number  itself
}

struct names{
string s;
lli score;
lli ind;
};

bool cmpfunc(names A , names B){
if(A.s == B.s)
    return(A.score>B.score);
return(A.s<B.s);
}
int main(){
lli n;
cin>>n;
names a[n];
loop(i,n){
cin>>a[i].s>>a[i].score;
a[i].ind = i+1;
}
sort(a,a+n,cmpfunc);
loop(i,n){
cout<<a[i].ind<<endl;
}
return 0;
}


Measured memory_bytes: 256