import std.stdio;
import std.algorithm;
import std.string;
import std.conv;
import std.range;

struct SP { string s; int p, n; }

void main() {
	int n;
	scanf("%d\n", &n);
	auto sp = new SP[n];
	foreach(i;0..n) {
		auto x = readln.chomp.split.array;
		sp[i] = SP(x[0], x[1].to!int, i);
	}
	sp.sort!((a, b) => a.p > b.p);
	sp.sort!((a, b) => a.s < b.s);
	foreach(x; sp) {
		(x.n+1).writeln;
	}
}
