import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{
    long n;
    scan(n);

    auto SP = new Tuple!(string, long, long)[](n);
    foreach (i; 0 .. n)
    {
        string s;
        long p;
        scan(s, p);
        SP[i] = Tuple!(string, long, long)(s, -p, (i + 1));
    }
    // writeln(SP);
    SP.sort();
    // writeln(SP);
    foreach (i; 0 .. n)
    {
        writeln(SP[i][2]);
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}
