#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N = 1005;

namespace flow {
	const int V = 2010, E = 30004;
	const ll inf = 1e16;
	int S, T, tot = 1, nxt[E], fst[V], to[E], cost[E], flow[E], pre[V]; ll dis[V];
	void link(int u, int v, int w, int c) {
		nxt[++tot] = fst[u]; fst[u] = tot; to[tot] = v; flow[tot] = w; cost[tot] = c;
		nxt[++tot] = fst[v]; fst[v] = tot; to[tot] = u; flow[tot] = 0; cost[tot] = -c;
	}
	bool spfa() {
		queue<int> q;
		static bool inq[V];
		for (int i = 0; i <= T; i++) dis[i] = inf;
		q.push(S), inq[S] = true, dis[S] = 0;
		while (!q.empty()) {
			int u = q.front(); q.pop(); inq[u] = false;
			for (int i = fst[u]; i; i = nxt[i])
				if (flow[i] > 0 && dis[to[i]] > dis[u] + cost[i]) {
					dis[to[i]] = dis[u] + cost[i];
					pre[to[i]] = i;
					if (!inq[to[i]]) q.push(to[i]), inq[to[i]] = true;
				}
		}
		return dis[T] != inf;
	}
	pair<int, ll> mcmf() {
		int f = 0;
		ll c = 0;
		while (spfa()) {
			int mn = 1 << 30;
			for (int i = T; i != S; i = to[pre[i] ^ 1]) mn = min(mn, flow[pre[i]]);
			f += mn, c += dis[T] * mn;
			for (int i = T; i != S; i = to[pre[i] ^ 1]) flow[pre[i]] -= mn, flow[pre[i] ^ 1] += mn;
		}
		return make_pair(f, c);
	}
}

int n;
struct node {
	int x, y, c;
}A[N], B[N];

//vector<int> qx, qy;

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
	{
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		A[i].x = a + b;
		A[i].y = a - b;
		A[i].c = c;
//		qx.push_back(A[i].x);
//		qy.push_back(A[i].y);
	}
	for(int i = 1; i <= n; ++i)
	{
		int a, b, c;
		scanf("%d %d %d", &a, &b, &c);
		B[i].x = a + b;
		B[i].y = a - b;
		B[i].c = c;
//		qx.push_back(B[i].x);
//		qy.push_back(B[i].y);
	}
	/*
	sort(qx.begin(), qx.end());
	qx.erase(unique(qx.begin(), qx.end()), qx.end());
	sort(qy.begin(), qy.end());
	qy.erase(unique(qy.begin(), qy.end()), qy.end());
	int aa = qx.size(), bb = qy.size();
	flow::S = (n + aa + bb) * 2 + 1;
	flow::T = flow::S + 1;
	for(int i = 1; i <= n; ++i)
	{
		flow::link(flow::S, i, A[i].c, 0);
		flow::link(i + n, flow::T, B[i].c, 0);
		flow::link(i, lower_bound(qx.begin(), qx.end(), A[i].x) - qx.begin() + n + n + 1, 1e9, 0);
		flow::link(i, lower_bound(qx.begin(), qx.end(), A[i].x) - qx.begin() + n + n + aa + 1, 1e9, 0);
		flow::link(i, lower_bound(qy.begin(), qy.end(), A[i].y) - qy.begin() + n + n + aa + aa + 1, 1e9, 0);
		flow::link(i, lower_bound(qy.begin(), qy.end(), A[i].y) - qy.begin() + n + n + aa + aa + bb + 1, 1e9, 0);
		flow::link(lower_bound(qx.begin(), qx.end(), B[i].x) - qx.begin() + n + n + 1, i + n, 1e9, 0);
		flow::link(lower_bound(qx.begin(), qx.end(), B[i].x) - qx.begin() + n + n + aa + 1, i + n, 1e9, 0);
		flow::link(lower_bound(qy.begin(), qy.end(), B[i].y) - qy.begin() + n + n + aa + aa + 1, i + n, 1e9, 0);
		flow::link(lower_bound(qy.begin(), qy.end(), B[i].y) - qy.begin() + n + n + aa + aa + bb + 1, i + n, 1e9, 0);
	}
	for(int i = 0; i + 1 < aa; ++i)
	{
		flow::link(n + n + i + 1, n + n + i + 2, 1e9, qx[i] - qx[i + 1]);
		flow::link(n + n + i + aa + 2, n + n + i + aa + 1, 1e9, qx[i] - qx[i + 1]);
	}
	for(int i = 0; i + 1 < bb; ++i)
	{
		flow::link(n + n + aa + aa + i + 1, n + n + aa + aa + i + 2, 1e9, qy[i] - qy[i + 1]);
		flow::link(n + n + aa + aa + bb + i + 2, n + n + aa + aa + bb + i + 1, 1e9, qy[i] - qy[i + 1]);
	}*/
	flow::S = n + n + 5;
	flow::T = flow::S + 1;
	for(int i = 1; i <= n; ++i)
	{
		flow::link(flow::S, i, A[i].c, 0);
		flow::link(i + n, flow::T, B[i].c, 0);
		
		// max{|x1 - x2|, |y1 - y2|}
		// = max{x1 - x2, x2 - x1, y1 - y2, y2 - y1}
		
		flow::link(i, n + n + 1, A[i].c, -A[i].x);
		flow::link(n + n + 1, i + n, B[i].c, B[i].x);
		
		flow::link(i, n + n + 2, A[i].c, A[i].x);
		flow::link(n + n + 2, i + n, B[i].c, -B[i].x);
		
		flow::link(i, n + n + 3, A[i].c, -A[i].y);
		flow::link(n + n + 3, i + n, B[i].c, B[i].y);
		
		flow::link(i, n + n + 4, A[i].c, A[i].y);
		flow::link(n + n + 4, i + n, B[i].c, -B[i].y);
	}
	auto res = flow::mcmf();
	printf("%lld", -res.second);
	return 0;
}


Measured memory_bytes: 640