#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

class Edge{
public:
    Int from, to, rev;
    Int cost, lim;
    Edge(Int from, Int to, Int cost, Int lim = -1, Int rev = -1):
        from(from),to(to),cost(cost),lim(lim),rev(rev){}
};


class Graph{
public:
    Int n;
    Int m;
    vector<vector<Edge>> edge;
    Graph(Int n = 0):n(n),m(0){
        edge = vector<vector<Edge>>(n);
    }
    void add_edge(Int from, Int to, Int cost = 1, Int lim = -1)
        {
            if(lim == -1){
                edge[from].push_back(Edge(from, to, cost));
                return;
            }
            edge[from].push_back(Edge(from, to, cost, lim, edge[to].size()));
            edge[to].push_back(Edge(to, from, -cost, 0, edge[from].size() - 1));
        }
};



class MinCostFlow{
public:
    priority_queue<P, vector<P>, greater<P> > pq;
    vector<Int> dist;
    vector<Int> before;
    vector<Int> index;
    MinCostFlow(){}
    
    void Dijkstra(Graph &g, Int s){
        fill(dist.begin(), dist.end(), LINF);
        pq.push(P(0, s));
        dist[s] = 0;

        while(!pq.empty()){
            P tmp = pq.top();pq.pop();
            Int from = tmp.second;
            if(tmp.first > dist[from])continue;
            for(Int i = 0;i < g.edge[from].size();i++){
                auto e = g.edge[from][i];
                if(e.lim == 0)continue;
                if(dist[e.to] <= dist[from] + e.cost)continue;
                dist[e.to] = dist[from] + e.cost;
                before[e.to] =from;
                index[e.to] = i;
                pq.push(P(dist[e.to], e.to));
            }
        }
    }

    
    Int mcf(Graph &g, Int s, Int t, Int f){
        Int res = 0;
        dist = vector<Int>(g.n);
        before = vector<Int>(g.n);
        index = vector<Int>(g.n);
        while(f){
            Dijkstra(g, s);
            Int flow = f;
            for(Int now = t;now != s;){
                Int last = before[now];
                Int ind = index[now];
                auto &e = g.edge[last][ind];
                if(e.lim == 0 || e.to != now)return -1;
                flow = min(flow, e.lim);
                now = last;
            }
            for(Int now = t;now != s;){
                Int last = before[now];
                Int ind = index[now];
                auto &e = g.edge[last][ind];
                e.lim -= flow;
                g.edge[e.to][e.rev].lim += flow;
                res += e.cost * flow;
                now = last;
            }
            f -= flow;
            if(flow==0)return -1;
        }
        return res;
    }
};
Int n, x, y, c;
Int csum = 0;
#define BIG 3000000000LL
int main(){
    cin >> n;
    MinCostFlow mcf;
    Graph g(2 * n + 4 + 2);
    Int s = 2 * n + 4;
    Int t = s + 1;
    Int base = 2 * n;
    for(int i = 0;i < n;i++){
        cin >> x >> y >> c;
        csum += c;
        g.add_edge(s, i, 0, c);
        g.add_edge(i, base + 0,  x + y + BIG, c);
        g.add_edge(i, base + 1,  x - y + BIG, c);
        g.add_edge(i, base + 2, -x + y + BIG, c);
        g.add_edge(i, base + 3, -x - y + BIG, c);
    }
    
    for(int i = 0;i < n;i++){
        cin >> x >> y >> c;
        g.add_edge(n + i, t, 0, c);
        g.add_edge(base + 0, n+i, -x - y + BIG, c);
        g.add_edge(base + 1, n+i, -x + y + BIG, c);
        g.add_edge(base + 2, n+i,  x - y + BIG, c);
        g.add_edge(base + 3, n+i,  x + y + BIG, c);
    }
    Int ans = mcf.mcf(g, s, t, csum);
    ans -= BIG * 2 * csum;
    cout << -ans << endl;
    return 0;
}

Measured memory_bytes: 1792