#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (100010)
#define P ()
#define M (N<<1)
#define inf (1e18)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,m,S,T,V,E=1,fi[N],ne[M],b[M],pre[N],prv[N];
LL dis[N],fl,mx,c[M],cap[M]; bool vis[N];
void add(int x,int y,LL cp,int cost){
//	cout<<x<<" "<<y<<" "<<cp<<" "<<cost<<endl;
	ne[++E]=fi[x],fi[x]=E,b[E]=y,cap[E]=cp,c[E]=cost;
	ne[++E]=fi[y],fi[y]=E,b[E]=x,cap[E]=0,c[E]=-cost;
}
void mcmf(int S,int T,LL flow){
	while(flow){
		for(int i=1;i<=V;i++)dis[i]=inf,vis[i]=0;
		dis[S]=0; queue<int> Q; Q.push(S),vis[S]=1;
		while(!Q.empty()){
			int u=Q.front();Q.pop(),vis[u]=0;
			if(dis[u]==inf)continue;
			for(int i=fi[u];i;i=ne[i]){
				int v=b[i];
				if(cap[i]>0&&dis[u]+c[i]<dis[v]){
                    dis[v]=dis[u]+c[i];
                    prv[v]=u,pre[v]=i;
                    if(!vis[v])Q.push(v),vis[v]=1;
                }
			}
		}
		if(dis[T]==inf)break;
		LL w=flow;
		for(int i=T;i!=S;i=prv[i])
		w=min(w,cap[pre[i]]);
		flow-=w,mx+=w*dis[T],fl+=w;
		for(int i=T;i!=S;i=prv[i]){
			int e=pre[i];
			cap[e]-=w,cap[e^1]+=w;
		}
	}
}
int main(){
	read(n),S=n*2+5,T=S+1,V=T; 
	for(int i=1;i<=n;i++){
		int x,y,z;
		read(x),read(y),read(z);
		add(S,i,z,0);
		add(i,n*2+1,inf,-x-y);
		add(i,n*2+2,inf,-x+y);
		add(i,n*2+3,inf,x-y);
		add(i,n*2+4,inf,x+y);
	}
	for(int i=1;i<=n;i++){
		int x,y,z;
		read(x),read(y),read(z);
		add(i+n,T,z,0);
		add(n*2+1,i+n,inf,x+y);
		add(n*2+2,i+n,inf,x-y);
		add(n*2+3,i+n,inf,-x+y);
		add(n*2+4,i+n,inf,-x-y); 
	}
	mcmf(S,T,inf),printf("%lld\n",-mx);
}

Measured memory_bytes: 6784