n = gets.to_i

h = Hash.new{|h,k| h[k] = []}
n.times do |i|
  s, p = gets.split(" ")
  h[s] << [i, p.to_i]
end

h = h.sort_by{|h,k| h}

h.length.times do |i|
  t = h[i][1].sort_by{|a,b| -b}
  t.length.times do |j|
    puts t[j][0] + 1
  end
end
 