import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
void main()
{
    auto n = lread();
    auto sp = new Tuple!(string, long, long)[](n);
    // writeln(sp);
    foreach (i; 0 .. n)
    {
        string s;
        long p;
        scan(s, p);
        sp[i][0] = s;
        sp[i][1] = -p;
        sp[i][2] = (i + 1);
    }
    sp.sort();
    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;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}
