def calc_time(dist, weight)
  [dist, weight]
  dist.to_f / (2000.0 / (70 + (weight * 20)))
end

until (n = gets) == nil
  hash = {}
  kura = []
  answer = []
  min = 0
  n = n.to_i
  n.times do
    ary = gets.split.map(&:to_i)
    hash[ary[0]] = *ary[1..2]
    kura << ary[0]
  end
  kura.permutation(n) do |item|
    p item
    kuras = []
    time = 0
    first_kura = item.shift
    kuras << first_kura
    tmp_dist = hash[first_kura][0]
    weight = hash[first_kura][1]
    item.each do |item2|
      kuras << item2
      dist = (hash[item2][0] - tmp_dist).abs
      tmp_dist = hash[item2][0]
      time += calc_time(dist, weight)
      weight += hash[item2][1]
    end
    p time
    if min > time or min == 0
      min = time
      answer = kuras
    end
  end
  p min
  puts answer.join(" ")
end