"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var n,a,ans;
var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  n = next();
  a = nextm(n,3);
  ans = xArray(1e15,n+1);
  var b = Array(n);
  for(var i = 0; i < n; i++)b[i] = Math.min(Math.abs(a[i][0]),Math.abs(a[i][1]));
  dfs(0,0,b);
  return ans.join("\n");
}

function dfs(id,cnt,b){
  if(id === n){
    var t = 0;
    for(var i = 0; i < n; i++)t += b[i]*a[i][2];
    if(ans[cnt] > t)ans[cnt] = t;
    return;
  }
  var c = Array(n);
  dfs(id+1,cnt,b);
  cnt++;
  for(var i = 0; i < n; i++){
    c[i] = Math.min(b[i],Math.abs(a[i][0]-a[id][0]));
  }
  dfs(id+1,cnt,c);
  for(var i = 0; i < n; i++){
    c[i] = Math.min(b[i],Math.abs(a[i][1]-a[id][1]));
  }
  dfs(id+1,cnt,c);
}