#include <bits/stdc++.h>
using namespace std;
void getint(int &v) {
  char ch, fu = 0;
  for (ch = '*'; (ch < '0' || ch > '9') && ch != '-'; ch = getchar())
    ;
  if (ch == '-') fu = 1, ch = getchar();
  for (v = 0; ch >= '0' && ch <= '9'; ch = getchar()) v = v * 10 + ch - '0';
  if (fu) v = -v;
}
int n[4], x, y, dep[4][100010], siz[4][100010];
long long d[4][100010], s[4], F[4][100010], G[4][100010], f[4][100010],
    D[4][100010], ANS, ans;
vector<int> v[4][100010];
void dfs(int h, int x, int l) {
  siz[h][x] = 1;
  d[h][x] = 0ll;
  dep[h][x] = dep[h][l] + 1;
  for (int i = 0; i < v[h][x].size(); ++i) {
    int y = v[h][x][i];
    if (y == l) continue;
    dfs(h, y, x);
    siz[h][x] += siz[h][y];
    d[h][x] += d[h][y] + siz[h][y];
  }
}
void DFS(int h, int x, int l) {
  for (int i = 0; i < v[h][x].size(); ++i) {
    int y = v[h][x][i];
    if (y == l) continue;
    D[h][y] = d[h][x] - d[h][y] - siz[h][y] + D[h][x] + n[h] - siz[h][y];
    DFS(h, y, x);
  }
}
void dfs1(int h, int x, int l, int na, int nc) {
  long long F1 = f[h][x] * na + 1ll * dep[h][x] * na * nc;
  long long G1 = f[h][x] * nc + 1ll * dep[h][x] * na * nc;
  ANS = max(ANS, F1 + G1 - 1ll * dep[h][x] * na * nc * 2);
  for (int i = 0; i < v[h][x].size(); ++i) {
    int y = v[h][x][i];
    if (y == l) continue;
    dfs1(h, y, x, na, nc);
    ANS = max(ANS, F[h][y] + G1 - 1ll * dep[h][x] * na * nc * 2);
    ANS = max(ANS, G[h][y] + F1 - 1ll * dep[h][x] * na * nc * 2);
    F1 = max(F1, F[h][y]);
    G1 = max(G1, G[h][y]);
  }
  F[h][x] = F1, G[h][x] = G1;
}
void doit(int A, int B, int C) {
  long long a = 0, c = 0;
  for (int i = 1; i <= n[A]; ++i) a = max(a, f[A][i]);
  for (int i = 1; i <= n[C]; ++i) c = max(c, f[C][i]);
  long long tmp = s[A] + s[C] + s[B];
  tmp += a * (n[B] + n[C]) + c * (n[A] + n[B]);
  tmp += 1ll * n[A] * (n[B] + n[C]) + 1ll * (n[A] + n[B]) * n[C];
  ANS = 0;
  dfs1(B, 1, 0, n[A], n[C]);
  tmp += ANS;
  ans = max(ans, tmp);
}
int main() {
  cin >> n[1] >> n[2] >> n[3];
  for (int i = 2; i <= n[1]; ++i) {
    getint(x), getint(y);
    v[1][x].push_back(y);
    v[1][y].push_back(x);
  }
  for (int i = 2; i <= n[2]; ++i) {
    getint(x), getint(y);
    v[2][x].push_back(y);
    v[2][y].push_back(x);
  }
  for (int i = 2; i <= n[3]; ++i) {
    getint(x), getint(y);
    v[3][x].push_back(y);
    v[3][y].push_back(x);
  }
  dfs(1, 1, 0);
  dfs(2, 1, 0);
  dfs(3, 1, 0);
  DFS(1, 1, 0);
  DFS(2, 1, 0);
  DFS(3, 1, 0);
  for (int rp = 1; rp <= 3; ++rp) {
    s[rp] = 0;
    for (int i = 1; i <= n[rp]; ++i) {
      f[rp][i] = d[rp][i] + D[rp][i];
      s[rp] += f[rp][i];
    }
    s[rp] /= 2;
  }
  doit(2, 1, 3);
  doit(1, 2, 3);
  doit(1, 3, 2);
  cout << ans << endl;
  return 0;
}
