import kotlin.math.abs
import kotlin.math.min

fun main() = msolutions2020e()

@OptIn(ExperimentalStdlibApi::class)
fun msolutions2020e() {
    val n = readLine()!!.toInt()
    val xList = IntArray(n)
    val yList = IntArray(n)
    val pList = IntArray(n)
    repeat(n) { i ->
        val (x, y, p) = readLine()!!.split(" ").map { it.toInt() }
        xList[i] = x
        yList[i] = y
        pList[i] = p
    }

    val choosePatterns = 1 shl n
    // 何もしてないのときの移動距離
    val baseDistances = (0 until n).map { min(abs(yList[it]), abs(xList[it])) }.toIntArray()
    // [その集合の街を基準に『横』に線路を引いたとき][i番目の街の] = 移動距離の最小
    val costsVert = Array(choosePatterns) { baseDistances.copyOf() }
    // [その集合の街を基準に『縦』に線路を引いたとき][i番目の街の] = 移動距離の最小
    val costsHorz = Array(choosePatterns) { baseDistances.copyOf() }

    val diffVert = Array(n) { IntArray(n) { Int.MAX_VALUE } }
    val diffHorz = Array(n) { IntArray(n) { Int.MAX_VALUE } }

    for (from in 0 until n) for (to in 0 until n) {
        diffVert[from][to] = min(diffVert[from][to], abs(yList[from] - yList[to]))
        diffHorz[from][to] = min(diffHorz[from][to], abs(xList[from] - xList[to]))
    }

    for (choose in 0 until choosePatterns) {
        for (from in (0 until n)) {
            if ((choose shr from) and 1 == 0) continue
            for (to in 0 until n) {
                costsVert[choose][to] = min(costsVert[choose][to], diffVert[from][to])
                costsHorz[choose][to] = min(costsHorz[choose][to], diffHorz[from][to])
            }
        }
    }

    val answers = LongArray(n + 1) { Long.MAX_VALUE }

    for (i in 0 until (3).simplePowExact(n)) {
        var chooseVertBit = 0
        var chooseHorzBit = 0
        var bitOfChooseTypes = i
        var bitOfDigit2 = 1

        while (bitOfChooseTypes > 0) {
            when (bitOfChooseTypes % 3) {
                1 -> chooseVertBit = chooseVertBit or bitOfDigit2
                2 -> chooseHorzBit = chooseHorzBit or bitOfDigit2
            }
            bitOfDigit2 = bitOfDigit2 shl 1
            bitOfChooseTypes /= 3
        }

        var costSum = 0L
        for (i in 0 until n) {
            costSum += min(costsVert[chooseVertBit][i], costsHorz[chooseHorzBit][i]).toLong() * pList[i]
        }
        
        val chooseCount = Integer.bitCount(chooseVertBit or chooseHorzBit)
        answers[chooseCount] = min(answers[chooseCount], costSum)
    }

    val answer = answers.joinToString(System.lineSeparator())

    println(answer)
}

private fun Int.simplePowExact(p: Int): Int {
    var x = 1
    repeat(p) { x = Math.multiplyExact(x, this) }
    return x
}
