#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
const long long mod = 1e5 + 10;
long long n[4], ans;
long long sz[N];
long long f[N][2], g[N][2][2], tmp[N][2][2];
vector<long long> vi[4][N];
void dfs1(long long base, long long pre, long long u, long long rem) {
  f[u][0] = f[u][1] = 0;
  sz[u] = 1;
  for (long long v : vi[base][u])
    if (v != pre) {
      dfs1(base, u, v, rem);
      sz[u] += sz[v];
      f[u][0] += f[v][0];
    }
  f[u][1] = (n[base] - sz[u]) * (rem + sz[u]) + f[u][0] + rem * n[base];
  for (long long v : vi[base][u])
    if (v != pre) {
      f[u][1] = max(f[u][1], f[u][0] - f[v][0] + f[v][1] +
                                 (n[base] - sz[u]) * (sz[u] + rem));
    }
  f[u][0] += sz[u] * (n[base] - sz[u] + rem);
}
void upd(long long &x, long long y) { x = max(x, y); }
void dfs2(long long base, long long pre, long long u, long long rem1,
          long long rem2) {
  memset(g[u], 0, sizeof g[u]);
  sz[u] = 1;
  long long cnt = 0;
  for (long long v : vi[base][u])
    if (v != pre) {
      dfs2(base, u, v, rem1, rem2);
      sz[u] += sz[v];
    }
  for (long long i = 0; i <= vi[base][u].size() + 1; ++i)
    memset(tmp[i], 0, sizeof tmp[i]);
  for (long long v : vi[base][u])
    if (v != pre) {
      cnt++;
      for (long long i = 0; i <= 1; ++i)
        for (long long j = 0; j <= 1; ++j) {
          upd(tmp[cnt][i][j], tmp[cnt - 1][i][j] + g[v][0][0]);
          if (j == 1) upd(tmp[cnt][i][j], tmp[cnt - 1][i][0] + g[v][0][1]);
          if (i == 1) upd(tmp[cnt][i][j], tmp[cnt - 1][0][j] + g[v][1][0]);
          if (i && j) upd(tmp[cnt][i][j], tmp[cnt - 1][0][0] + g[v][1][1]);
        }
    }
  for (long long i = 0; i <= 1; ++i)
    for (long long j = 0; j <= 1; ++j) {
      long long s1 = n[base] - sz[u];
      if (i == 0) s1 += rem1;
      if (j == 0) s1 += rem2;
      long long s2 = sz[u];
      if (i) s2 += rem1;
      if (j) s2 += rem2;
      g[u][i][j] = tmp[cnt][i][j] + s1 * s2;
      long long val = rem1 * (rem2 + n[base]);
      if (i == 1) upd(g[u][i][j], tmp[cnt][0][j] + s1 * s2 + val);
      val = rem2 * (rem1 + n[base]);
      if (j == 1) upd(g[u][i][j], tmp[cnt][i][0] + s1 * s2 + val);
      val = rem1 * (rem2 + n[base]) + rem2 * (rem1 + n[base]);
      if (i > 0 && j > 0) upd(g[u][i][j], tmp[cnt][0][0] + s1 * s2 + val);
    }
}
void solve(vector<long long> tmp) {
  long long sum = n[tmp[0]] + n[tmp[1]];
  dfs1(tmp[2], 1, 1, sum);
  long long p1 = f[1][1];
  sum = n[tmp[0]] + n[tmp[2]];
  dfs1(tmp[1], 1, 1, sum);
  long long p2 = f[1][1];
  dfs2(tmp[0], 1, 1, n[tmp[1]], n[tmp[2]]);
  long long p3 = g[1][1][1];
  ans = max(ans, p1 + p2 + p3 - n[tmp[1]] * (n[tmp[0]] + n[tmp[2]]) -
                     n[tmp[2]] * (n[tmp[0]] + n[tmp[1]]));
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 1; i <= 3; ++i) cin >> n[i];
  for (long long i = 1; i <= 3; ++i) {
    for (long long j = 1; j <= n[i] - 1; ++j) {
      long long u, v;
      cin >> u >> v;
      vi[i][u].push_back(v);
      vi[i][v].push_back(u);
    }
  }
  vector<long long> tmp;
  for (long long i = 1; i <= 3; ++i) tmp.push_back(i);
  solve(tmp);
  swap(tmp[0], tmp[1]);
  solve(tmp);
  swap(tmp[0], tmp[2]);
  solve(tmp);
  cout << ans;
}
