def min(a,b); a < b ? a : b; end
def max(a,b); a > b ? a : b; end

class Town
  attr_accessor :x, :y, :p

  def initialize(x, y, p)
    @x = x
    @y = y
    @p = p
  end

  def profitX(ox)
    newdist = min((x-ox).abs, y.abs) * p
    newdist < distance ? distance - newdist : 0
  end

  def profitY(oy)
    newdist = min(x.abs, (y-oy).abs) * p
    newdist < distance ? distance - newdist : 0
  end

  def distance
    min(x.abs, y.abs) * p
  end
end

class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)

  def initialize
    @n = gets.to_s.to_i
    @a = Array.new(n) { Town.new(*gets.to_s.split.map { |v| v.to_i }) }
    @b = @a.map(&:x).uniq
    @c = @a.map(&:y).uniq
    @m = [@b.size, @c.size].min
  end

  def solve
    0.upto(n) do |i|
      show(calc(i))
    end
  end

  def calc(i)
    return sum if i == 0
    return 0 if m <= i

    bs = b.map{|x|a.map{ _1.profitX(x) }.sum}
    cs = c.map{|y|a.map{ _1.profitY(y) }.sum}
    profit = (bs+cs).sort.reverse.take(i).sum
    max(sum - profit, 0)
  end

  def sum
    @sum ||= a.map(&:distance).sum
  end

  def show(ans)
    puts ans
  end
end

Problem.new.instance_eval do
  solve
  # show(solve)
  # pp self
end
