n = STDIN.gets.chomp.to_i
a = []
i = 1
STDIN.each{|x|
  data = x.chomp.split(" ")
  a.push([data[0], data[1].to_i, i])
  i += 1
  }

a.sort!{|x, y| y[1] <=> x[1]}
a.sort!{|x, y| x[0] <=> y[0]}

a.each{|x|
  puts x[2]
  }