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

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

alias City = Tuple!(string, "s", int, "p", int, "i");

void main(){
  auto n = readNum!int;
  City[] c;

  foreach(i; 0 .. n){
    string[] s = readln.chomp.split;
    c ~= City(s[0], s[1].to!int, i+1);
  }

  c = c.multiSort!("a.s < b.s", "a.p > b.p").array;
  foreach(e; c){
    writeln(e.i);
  }
}
