#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
vector<int> mp[3][100005];
int num[3], sz[3][100005];
long long dis[3][100005], ans, len[3][100005];
int mT[3];
void dfs(int id, int x, int pa) {
  sz[id][x] = 1;
  dis[id][x] = 0;
  for (int c : mp[id][x])
    if (c != pa) {
      dfs(id, c, x);
      sz[id][x] += sz[id][c];
      dis[id][x] += dis[id][c] + sz[id][c];
    }
}
long long tmp, mtmp;
void dfs1(int id, int x, int pa, long long val) {
  long long newdis = val + (n - sz[id][x]);
  long long aa = dis[id][x] + newdis;
  tmp += aa;
  if (aa > mtmp) {
    mtmp = aa;
    mT[id] = x;
  }
  dis[id][x] = aa;
  for (int c : mp[id][x])
    if (c != pa) {
      long long zz = dis[id][c] + sz[id][c];
      dfs1(id, c, x, dis[id][x] - zz);
    }
}
void dfsLen(int id, int x, int pa, int dp) {
  len[id][x] = dp;
  for (int c : mp[id][x])
    if (c != pa) {
      dfsLen(id, c, x, dp + 1);
    }
}
void cal(int id) {
  n = num[id];
  for (int i = 0, u, v; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    mp[id][u].push_back(v);
    mp[id][v].push_back(u);
  }
  dfs(id, 1, 0);
  tmp = dis[id][1];
  mtmp = tmp;
  mT[id] = 1;
  for (int c : mp[id][1]) {
    long long zz = dis[id][c] + sz[id][c];
    dfs1(id, c, 1, dis[id][1] - zz);
  }
  assert(tmp % 2 == 0);
  ans += tmp / 2;
  int node = mT[id];
  dfsLen(id, node, 0, 0);
}
long long Add;
void dd(int L, int mid, int R) {
  long long n1 = num[L], n2 = num[mid], n3 = num[R];
  long long tmp = n1 * n2 + dis[L][mT[L]] * n2 + dis[mid][mT[mid]] * n1;
  tmp += dis[L][mT[L]] * n3 + dis[R][mT[R]] * n1 + 2LL * n1 * n3;
  for (int(i) = 1; (i) <= (int)(n2); (i)++) {
    long long z = dis[mid][i] * n3 + n2 * n3 + dis[R][mT[R]] * n2;
    z += n1 * n3 * len[mid][i];
    z += tmp;
    Add = max(Add, z);
  }
}
int main() {
  for (int(i) = 0; (i) < (int)(3); (i)++) scanf("%d", num + i);
  for (int(i) = 0; (i) < (int)(3); (i)++) cal(i);
  for (int(i) = 0; (i) < (int)(3); (i)++)
    for (int(j) = 0; (j) < (int)(3); (j)++)
      if (i != j) {
        dd(i, j, 3 - i - j);
      }
  printf("%lld\n", ans + Add);
  return 0;
}
