import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

alias A = Tuple!(int, "no", string, "name", int, "value");

void main() {
    int n; scan(n);
    A[] a;
    for (int i = 0; i < n; i++) {
        string name;
        int value;
        scan(name, value);
        a ~= A(i + 1, name, value);
    }

    a.sort!((a, b) => a.name == b.name ? a.value > b.value : a.name < b.name);
    foreach (e; a) {
        writeln(e.no);
    }
}
