require 'set'; require 'prime'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
a = []
n.times do |i|
  city, num = gets.chomp.split
  a.push [i+1, city, num.to_i]
end

j = 0
a.sort_by{|i,x,y| -y}.sort_by{|i,x,y| [x, j+=1]}.each do |i,x,y|
  puts i
end
