#define George_Plover
#include <queue>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 3000
#define MAXM 3000000
#define INF 2147483647
using namespace std;
int n,m,tx,ty,tz,T0,T1,T2,T3;
int S,T;
int pre[MAXN],tot=1,to[MAXM],lin[MAXM],cost[MAXM],flow[MAXM],in[MAXN];
LL dis[MAXN];
int bx[MAXN],by[MAXN];
bool vis[MAXN];
queue <int> q;
void add(int x,int y,int v,int f)
{
    tot++;
    lin[tot]=pre[x];
    pre[x]=tot;
    to[tot]=y;
    cost[tot]=v;
    flow[tot]=f;
    
    tot++;
    lin[tot]=pre[y];
    pre[y]=tot;
    to[tot]=x;
    cost[tot]=-v;
    flow[tot]=0;
}
bool SPFA()
{
    for(int i=0;i<MAXN;i++)
    {
        dis[i]=(1ll<<61);
    }
    memset(in,0,sizeof(in));
    dis[S]=0;
    q.push(S);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        vis[u]=0;
        
        for(int i=pre[u];i;i=lin[i])
        {
            int v=to[i];
            if(flow[i]&&dis[v]>dis[u]+cost[i])
            {
                dis[v]=dis[u]+cost[i];
                in[v]=i;
                if(!vis[v])
                {
                    vis[v]=1;
                    q.push(v);
                }
            }
        }
    }
    return dis[T]!=dis[0];
}

LL adjust()
{
    LL ret=2147483647;
    for(int i=T;i!=S;i=to[in[i]^1])
    {
        ret=(ret<flow[in[i]]?ret:flow[in[i]]);
    }
    for(int i=T;i!=S;i=to[in[i]^1])
    {
        flow[in[i]]-=ret;
        flow[in[i]^1]+=ret;
    }
    return ret*dis[T];
}

int main()
{
    scanf("%d",&n);
    S=n+n+2;
    T=S+1;T0=T+1;T1=T0+1;T2=T1+1;T3=T2+1;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&tx,&ty,&tz);
        bx[i]=tx;
        by[i]=ty;
        add(S,i,0,tz);
        add(i,T0,tx+ty,INF);
        add(i,T1,-tx+ty,INF);
        add(i,T2,tx-ty,INF);
        add(i,T3,-tx-ty,INF);
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&tx,&ty,&tz);
        add(i+n,T,0,tz);
        add(T0,n+i,-tx-ty,INF);
        add(T1,n+i,tx-ty,INF);
        add(T2,n+i,-tx+ty,INF);
        add(T3,n+i,tx+ty,INF);
    }
    
    LL ans=0;
    
    while(SPFA())
    {
        ans+=adjust();
    }
    
    cout<<-ans<<endl;
    return 0;
}
