n = gets.to_i
c, p = n.times.map{gets.chomp.split}.transpose
city = Array.new(0)
for i in 0..(n-1)
  city.push(c[i])
end
city.uniq!
city.sort!
city.each do |ci|
  po = Array.new(0)
  for i in 0..(n-1)
    if c[i] == ci
      po.push([p[i].to_i, i+1])
    end
  end
  po.sort!{|n1, n2| n2[0] <=> n1[0]}
  po.each do |ar|
    puts ar[1]
  end
end