#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace mcmf {
struct edge {
  int to, capacity, cost, back;
  edge(int a, int b, int c, int d): to(a), capacity(b), cost(c), back(d) {
  }
};
vector<vector<edge> > graph;
void add(int u, int v, int capacity, int cost) {
  graph[u].emplace_back(v, capacity, cost, (int)graph[v].size());
  graph[v].emplace_back(u, 0, -cost, (int)graph[u].size() - 1);
}
int s, t;
void init(int ss, int tt) {
  s = ss;
  t = tt;
  graph.resize(t + 1);
}
ll solve() {
  ll result = 0;
  while (true) {
    vector<ll> dist(t + 1, LLONG_MAX);
    vector<bool> in_queue(t + 1);
    vector<int> from_vertex(t + 1), from_edge(t + 1);
    queue<int> que;
    que.push(s);
    dist[s] = 0;
    in_queue[s] = true;
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      in_queue[u] = false;
      for (int i = 0; i < graph[u].size(); i++) {
        edge e = graph[u][i];
        if (e.capacity && dist[e.to] > dist[u] + e.cost) {
          dist[e.to] = dist[u] + e.cost;
          from_vertex[e.to] = u;
          from_edge[e.to] = i;
          if (!in_queue[e.to]) {
            que.push(e.to);
            in_queue[e.to] = true;
          }
        }
      }
    }
    if (dist[t] == LLONG_MAX) {
      break;
    }
    int capacity = INT_MAX;
    for (int u = t; u != s; u = from_vertex[u]) {
      capacity = min(capacity, graph[from_vertex[u]][from_edge[u]].capacity);
    }
    result += dist[t] * capacity;
    for (int u = t; u != s; u = from_vertex[u]) {
      graph[from_vertex[u]][from_edge[u]].capacity -= capacity;
      graph[u][graph[from_vertex[u]][from_edge[u]].back].capacity += capacity;
    }
  }
  return result;
}
}
int main() {
  do {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
  } while (false);
  int n;
  cin >> n;
  mcmf::init(0, n * 2 + 5);
  for (int i = 0; i < n; i++) {
    int x, y, count;
    cin >> x >> y >> count;
    mcmf::add(0, i + 1, count, 0);
    mcmf::add(i + 1, n + 1, count, x + y);
    mcmf::add(i + 1, n + 2, count, y - x);
    mcmf::add(i + 1, n + 3, count, x - y);
    mcmf::add(i + 1, n + 4, count, -x - y);
  }
  for (int i = 0; i < n; i++) {
    int x, y, count;
    cin >> x >> y >> count;
    mcmf::add(n + 4, i + n + 5, count, x + y);
    mcmf::add(n + 3, i + n + 5, count, y - x);
    mcmf::add(n + 2, i + n + 5, count, x - y);
    mcmf::add(n + 1, i + n + 5, count, -x - y);
    mcmf::add(i + n + 5, n * 2 + 5, count, 0);
  }
  cout << -mcmf::solve() << endl;
  return 0;
}
