n = gets.chomp.to_i
order = []
i = 1
while i <= n
  arr = gets.chomp.split(' ')
  order << [arr[0],arr[1].to_i,i]
  i += 1
end
# p order

# 順番を作る
i = 0
while i < order.size
  j = i+1
  while j < order.size
    if order[i][0] > order[j][0]
      tmp = order[i]
      order[i] = order[j]
      order[j] = tmp
    elsif order[i][0] == order[j][0] && order[i][1] < order[j][1]
      tmp = order[i]
      order[i] = order[j]
      order[j] = tmp
    end
    #  puts "i:#{order[i]}, j:#{order[j]}, j+1:#{order[j+1]}, a<b#{"kaqqqqqzan"<"moscow"}"
    j += 1
  end
  i += 1
end
# p order
order.each {|x| puts x[2]}