import std.stdio, std.string, std.array, std.conv, std.typecons, std.algorithm;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

void main() {
    immutable n = readln.chomp.to!(ulong);

    auto vs = new Tuple!(ulong, "n", string, "s", ulong, "p")[n];
    for (ulong i = 0; i < n; i++) {
        immutable ip = readln.split;
        vs[i].n = i+1;
        vs[i].s = ip[0];
        vs[i].p = ip[1].to!(ulong);
    }

    vs.sort!((a, b) {
            if (a.s == b.s) return a.p > b.p;
            return a.s < b.s;
            });

    foreach(v ; vs) {
        writeln(v.n);
    }
}
