#include <bits/stdc++.h>

#define F(i, a, b) for (ll i = a; i <= b; i ++)
#define G(i, a, b) for (ll i = a; i >= b; i --)
#define out4(x, y, z, w) { if (debug) printf(#x" = "),W(x),printf(" "#y" = "),W(y),printf(" "#z" = "),W(z),printf(" "#w" = "),W(w),putc('\n'); }
#define out3(x, y, z) { if (debug) printf(#x" = "), W(x), printf(" "#y" = "), W(y), printf(" "#z" = "), W(z), putc('\n'); }
#define out2(x, y) { if (debug) printf(#x" = "), W(x), printf(" "#y" = "), W(y), putc('\n'); }
#define out1(x) { if (debug) printf(#x" = "), W(x), putc('\n'); }
#define outline(x) { if (debug) puts("-------------------------------------------"#x"----------------------------------------"); }
#define outarr(a, L, R) { if (debug) { printf(#a"[%d..%d] = ", L, R); F(i, L, R) W(a[i]), putc(' '); putc('\n'); } }
#define Assert(x) { if ((debug) && (!(x))) { puts("Wrong Answer"); exit(0); } }
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define mem(a, b) memset(a, b, sizeof a)
#define mec(a, b) memcpy(a, b, sizeof a)
#define mx(a, b) ((a) = max(a, b))
#define mn(a, b) ((a) = min(a, b))
#define lowbit(x) ((x) & (-(x)))
#define abs(x) ((max(x, - (x))))
#define get getchar()
#define pb push_back
#define putc putchar
#define inf 2e18

template <typename Int>
void R(Int &x) {
	char c = get; x = 0; Int t = 1;
	for (; !isdigit(c); c = get) t = (c == '-' ? - 1 : t);
	for (; isdigit(c); x = (x << 3) + (x << 1) + c - '0', c = get); x *= t;
}
template <typename Int>
void W(Int x) {
	if (x < 0) { putc('-'); x = - x ; }
	if (x > 9) W(x / 10); putc(x % 10 + '0');
}

#define debug (0)

using namespace std;

#define ll long long
const ll N = 3e3 + 10;
const ll M = 3e5 + 10;
ll n, x, y, c, S, T, tot, Ans;
ll tov[M], nex[M], len[M], cost[M], las[N];
ll dis[N], inc[N], bz[N], pre[N];

void link(ll x, ll y, ll c, ll v) {
//	out4(x, y, c, v);
	tov[++ tot] = y, nex[tot] = las[x], las[x] = tot, len[tot] = c, cost[tot] = + v;
	tov[++ tot] = x, nex[tot] = las[y], las[y] = tot, len[tot] = 0, cost[tot] = - v;
}

bool spfa() {
	mem(dis, 128), dis[S] = 0, inc[S] = inf, bz[S] = 1;
	queue <ll> Q; Q.push(S);
	while (Q.size()) {
		ll k = Q.front(); Q.pop();
		for (ll x = las[k], p; x; x = nex[x]) {
			p = tov[x];
			if (len[x] && dis[p] < dis[k] + cost[x]) {
				dis[p] = dis[k] + cost[x];
				inc[p] = min(inc[k], len[x]);
				pre[p] = x;
				if (!bz[p])
					Q.push(p), bz[p] = 1;
			}
		}
		bz[k] = 0;
	}
	outarr(dis, 1, T);
	return dis[T] >= 0;
}

int main() {
//	freopen("data.in","r",stdin);

	R(n), S = 2 * n + 9, T = S + 1, tot = 1;
	F(i, 1, n) {
		R(x), R(y), R(c);
		link(S, i, c, 0);
		link(i, n + 1, c, + x + y);
		link(i, n + 2, c, + x - y);
		link(i, n + 3, c, - x + y);
		link(i, n + 4, c, - x - y);
	}

	F(i, 1, 4) link(n + i, n + 4 + i, inf, 0);

	F(i, 1, n) {
		R(x), R(y), R(c);
		link(n + 8 + i, T, c, 0);
		link(n + 5, n + 8 + i, c, - x - y);
		link(n + 6, n + 8 + i, c, - x + y);
		link(n + 7, n + 8 + i, c, + x - y);
		link(n + 8, n + 8 + i, c, + x + y);
	}

	long long Ans = 0;
	while (spfa()) {
		Ans += dis[T] * inc[T];
//		out2(dis[T], inc[T]);
		for (ll k = T; k ^ S; k = tov[pre[k] ^ 1]) {
			len[pre[k]] -= inc[T];
			len[pre[k] ^ 1] += inc[T];
//			out1(k);
		}
	}
	W(Ans);
}

Measured memory_bytes: 4348