#include<set>
#include<map>
#include<queue>
#include<cmath>
#include<string>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#define rep(i,a,b) for (int i=a; i<=b; i++)
#define per(i,a,b) for (int i=a; i>=b; i--)
using namespace std;

const int maxn=3010, maxm=2022000;
const long long inf=9999999999;
typedef long long LL;

struct Edge{
	Edge(){};
	Edge(int a,int b,LL c,int d){v=a;f=b;w=c;nxt=d;};
	int v,f,nxt;
	LL w;
};

int n,lmt;
int g[maxn+10];
Edge e[maxm+10];
int nume;
int src,sink;

void addedge(int u,int v,int c,LL w){
	e[++nume]=Edge(v,c,w,g[u]);
	g[u]=nume;
	e[++nume]=Edge(u,0,-w,g[v]);
	g[v]=nume;
}

queue<int> que;
bool inQue[maxn+10];
LL dist[maxn+10];
int pren[maxn+10];
int pree[maxn+10];

bool findPath(){
	while(!que.empty())que.pop();
	que.push(src);
	memset(dist,0x3f,sizeof(dist));
	dist[src]=0;inQue[src]=true;
	while(!que.empty()){
		int u=que.front();
		//cout<<u<<endl;
		que.pop();
		for(int i=g[u];i;i=e[i].nxt){
			if((e[i].f>0) && (dist[u]+e[i].w<dist[e[i].v])){
				dist[e[i].v]=dist[u]+e[i].w;
				pren[e[i].v]=u;pree[e[i].v]=i;
				if(!inQue[e[i].v]){
					inQue[e[i].v]=true;
					que.push(e[i].v);
				}
			}
		}
		inQue[u]=false;
	}
	if(dist[sink]<dist[3001])return true;
	return false;
}

LL augment(){
	int u=sink;
	LL delta=inf;
	while(u!=src){
		if(e[pree[u]].f<delta)delta=e[pree[u]].f;
		u=pren[u];
	}
	u=sink;
	while(u!=src){
		e[pree[u]].f-=delta;
		e[pree[u]^1].f+=delta;
		u=pren[u];
	}
	return dist[sink]*delta;
}

LL mincostflow(){
	LL cur=0;
	while(findPath()){
		cur+=augment();
		//rep(i,1,2*n+1)cout<<i<<" "<<dist[i]<<endl;
	}
	return cur;
}

int RX[1010],RY[1010],BX[1010],BY[1010];
int RC[1010],BC[1010];

int main() {
	std::ios::sync_with_stdio(false);
	cin>>n;
	rep(i,1,n)cin>>RX[i]>>RY[i]>>RC[i];
	rep(i,1,n)cin>>BX[i]>>BY[i]>>BC[i];
	sink=1;src=0;nume=1;
	memset(g,0,sizeof(g));
	rep(i,1,n)addedge(0,i+1,RC[i],0);
	rep(i,1,n)addedge(i+n+1,1,BC[i],0);
	rep(i,1,n){
		rep(j,1,n){
			addedge(i+1,j+n+1,10,-abs(RX[i]-BX[j])-abs(RY[i]-BY[j]));
		}
	}
	cout<<-mincostflow()<<endl;
	return 0;
}