#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e3 + 100;
bool mark[3][maxn], mark_ans[3][maxn];
long long dp[3][maxn], dp_down[3][maxn], sum_down[3][maxn], par[3][maxn],
    sz[3][maxn], ans[3][maxn];
vector<long long> v[3][maxn];
long long n[3], bst[3];
long long final_ans = 0;
long long dfs1(long long x, long long cls) {
  mark[cls][x] = true;
  sz[cls][x] = 1;
  for (long long i = 0; i < v[cls][x].size(); i++) {
    long long child = v[cls][x][i];
    if (!mark[cls][child]) {
      par[cls][child] = x;
      sz[cls][x] += dfs1(child, cls);
      sum_down[cls][x] += dp_down[cls][child];
      dp_down[cls][x] += dp_down[cls][child];
    }
  }
  dp_down[cls][x] += sz[cls][x] - 1;
  return sz[cls][x];
}
void dfs(long long x, long long cls) {
  if (par[cls][x] != 0) {
    dp[cls][x] = dp[cls][par[cls][x]];
    dp[cls][x] += sz[cls][1] - sz[cls][par[cls][x]] + 1;
    dp[cls][x] += sum_down[cls][par[cls][x]] - dp_down[cls][x] +
                  2 * (sz[cls][par[cls][x]] - sz[cls][x] - 1);
  }
  for (long long i = 0; i < v[cls][x].size(); i++) {
    long long child = v[cls][x][i];
    if (par[cls][child] != x) continue;
    dfs(child, cls);
  }
  ans[cls][x] = dp[cls][x] + dp_down[cls][x];
}
void dfs_ans(long long cls, long long y, long long x, long long d) {
  long long cur = 0;
  long long ind1, ind2;
  for (long long i = 0; i < 3; i++) {
    if (i != cls) {
      ind1 = i;
      break;
    }
  }
  for (long long i = 2; i >= 0; i--) {
    if (i != cls) {
      ind2 = i;
      break;
    }
  }
  cur += bst[ind1] * sz[cls][1] + ans[cls][y] * sz[ind1][1];
  cur += sz[ind1][1] * sz[cls][1];
  cur += bst[ind2] * sz[cls][1] + ans[cls][x] * sz[ind2][1];
  cur += sz[ind2][1] * sz[cls][1];
  cur += bst[ind1] * sz[ind2][1] + bst[ind2] * sz[ind1][1];
  cur += sz[ind1][1] * sz[ind2][1] * (d + 2);
  final_ans = max(final_ans, cur);
  mark_ans[cls][x] = true;
  for (long long i = 0; i < v[cls][x].size(); i++) {
    long long child = v[cls][x][i];
    if (!mark_ans[cls][child]) {
      dfs_ans(cls, y, child, d + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n[0] >> n[1] >> n[2];
  for (long long j = 0; j < 3; j++) {
    for (long long i = 1; i < n[j]; i++) {
      long long fi, se;
      cin >> fi >> se;
      v[j][fi].push_back(se);
      v[j][se].push_back(fi);
    }
  }
  for (long long i = 0; i < 3; i++) {
    dfs1(1, i);
    dfs(1, i);
    for (long long j = 1; j <= n[i]; j++) bst[i] = max(bst[i], ans[i][j]);
  }
  for (long long i = 0; i < 3; i++) {
    for (long long j = 1; j <= n[i]; j++) {
      memset(mark_ans, false, sizeof mark_ans);
      dfs_ans(i, j, j, 0);
    }
  }
  for (long long i = 0; i < 3; i++) {
    long long ons = 0;
    for (long long j = 1; j <= n[i]; j++) {
      ons += ans[i][j];
    }
    ons /= 2;
    final_ans += ons;
  }
  cout << final_ans << endl;
}
