import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(string, "s", long, "p");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto guide = new Pair[](n);
    foreach (i; iota(n))
    {
        string s;
        long p;
        scan(s, p);
        guide[i] = Pair(s, p);
    }
    auto book = guide.dup.sort!"a.s == b.s ? a.p > b.p : a.s < b.s"().array();
    // book.each!(x => x.writeln());
    foreach (e; book)
    {
        foreach (i, f; guide)
        {
            if(e == f)
                writeln(i + 1);
        }
    }
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
