loop do
    n = gets.to_i
    break if n == 0
    names, weights, powers = (1..n).map { gets.split }.transpose.map.with_index {|a, i| i > 0 ? a.map(&:to_i) : a}
    weight_sum = (0..2**n-1).map {|x| (0..n-1).map {|i| x[i] == 1 ? weights[i] : 0}.inject(:+)}

    g = Array.new(2**n, Float::INFINITY)
    g[0] = 0.0
    min_by = Array.new(2**n)
    min_by[0] = []

    (1..2**n-1).each do |x|
        (0..n-1).each do |i|
            if x[i] == 1
                y = x - (1 << i)
                next unless g[y]
                w = weight_sum[y]
                next if powers[i] < w
                m = w * (g[y] + 1.0) / (weights[i] + w)
                if m < g[x]
                    g[x] = m
                    min_by[x] = [i] + min_by[y]
                end
            end
        end
    end
    puts min_by[-1].map {|i| names[i]}
end

