//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<queue>
#define ll long long
#define inf 20021225
#define N 3100
#define M 100010
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
struct edge{int to,lt,f,c;}e[M];
int cnt=1,in[N],s,t,fr[N]; ll ans;
void add(int x,int y,int f,int c)
{
	e[++cnt].to=y; e[cnt].lt=in[x]; in[x]=cnt; e[cnt].f=f; e[cnt].c=c;
	e[++cnt].to=x; e[cnt].lt=in[y]; in[y]=cnt; e[cnt].f=0; e[cnt].c=-c;
}
queue<int> q; ll dis[N]; bool vis[N];
bool spfa()
{
	while(!q.empty())	q.pop();
	memset(dis,48,sizeof(dis));
	q.push(s); dis[s]=0;
	while(!q.empty())
	{
		int x=q.front(); q.pop(); vis[x]=0;
		for(int i=in[x];i;i=e[i].lt)
		{
			int y=e[i].to;
			if(e[i].f&&dis[y]>dis[x]+e[i].c)
			{
				dis[y]=dis[x]+e[i].c; fr[y]=i;
				if(!vis[y])	q.push(y),vis[y]=1;
			}
		}
	}
	return dis[t]!=dis[0];
}
void flow()
{
	int fl=inf; ll c=0;
	for(int i=t;i!=s;i=e[fr[i]^1].to)	fl=min(fl,e[fr[i]].f);
	for(int i=t;i!=s;i=e[fr[i]^1].to)	e[fr[i]].f-=fl,e[fr[i]^1].f+=fl;
	ans+=dis[t]*fl;
}
int main()
{
	int n=read(); s=N-2,t=s+1; int p=N-10;
	for(int i=1;i<=n;i++)
	{
		int x=read(),y=read(),f=read();
		add(s,i,f,0);
		add(i,p,f,-x-y);
		add(i,p+1,f,-x+y);
		add(i,p+2,f,x-y);
		add(i,p+3,f,x+y);
	}
	for(int i=1;i<=n;i++)
	{
		int x=read(),y=read(),f=read();
		add(i+n,t,f,0);
		add(p,i+n,f,x+y);
		add(p+1,i+n,f,x-y);
		add(p+2,i+n,f,-x+y);
		add(p+3,i+n,f,-x-y);
	}
	while(spfa())	flow();
	printf("%lld\n",-ans);
	return 0;
}