#include <bits/stdc++.h>

const int MAXN = 10010;
const int MAXM = MAXN * 10;
typedef long long LL;
int head[MAXN], nxt[MAXM], to[MAXM], val[MAXM], tot = 1;
LL dis[MAXN], cost[MAXM];
void addedge(int b, int e, int v, int c) {
	nxt[++tot] = head[b]; to[head[b] = tot] = e; val[tot] = v, cost[tot] = c;
	nxt[++tot] = head[e]; to[head[e] = tot] = b; val[tot] = 0, cost[tot] = -c;
}
std::queue<int> q;
int S, T, inq[MAXN], pre[MAXN];
bool bellmanford() {
	std::memset(dis, 0xcf, T - S + 1 << 3);
	q.push(S); dis[S] = 0; inq[S] = true;
	while (!q.empty()) {
		int t = q.front(); q.pop(); inq[t] = false;
		for (int i = head[t]; i; i = nxt[i]) {
			if (val[i] && dis[to[i]] < dis[t] + cost[i]) {
				dis[to[i]] = dis[t] + cost[i];
				pre[to[i]] = i ^ 1;
				if (!inq[to[i]]) {
					inq[to[i]] = true;
					q.push(to[i]);
				}
			}
		}
	}
	return dis[T] != (LL) 0xcfcfcfcfcfcfcfcfLL;
}
LL MCMF() {
	int minv = 0x3f3f3f3f, now = pre[T];
	while (now) {
		minv = std::min(minv, val[now ^ 1]);
		now = pre[to[now]];
	}
	now = pre[T];
	while (now) {
		val[now] += minv;
		val[now ^ 1] -= minv;
		now = pre[to[now]];
	}
	return minv * dis[T];
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	int n; std::cin >> n;
	S = 0, T = n * 2 + 5;
	for (int i = 1, t1, t2, t3; i <= n; ++i) {
		std::cin >> t1 >> t2 >> t3;
		addedge(S, i, t3, 0);
		addedge(i, n * 2 + 1, 0x3f3f3f3f, t1 + t2);
		addedge(i, n * 2 + 2, 0x3f3f3f3f, t1 - t2);
		addedge(i, n * 2 + 3, 0x3f3f3f3f, -t1 + t2);
		addedge(i, n * 2 + 4, 0x3f3f3f3f, -t1 - t2);
	}
	for (int i = 1, t1, t2, t3; i <= n; ++i) {
		std::cin >> t1 >> t2 >> t3;
		addedge(i + n, T, t3, 0);
		addedge(n * 2 + 1, i + n, 0x3f3f3f3f, - t1 - t2);
		addedge(n * 2 + 2, i + n, 0x3f3f3f3f, -t1 + t2);
		addedge(n * 2 + 3, i + n, 0x3f3f3f3f, t1 - t2);
		addedge(n * 2 + 4, i + n, 0x3f3f3f3f, t1 + t2);
	}
	LL ans = 0;
	while (bellmanford()) ans += MCMF();
	std::cout << ans << std::endl;
	return 0;
}