#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int n1, n2, n3, size[MAXN];
vector<int> e1[MAXN], e2[MAXN], e3[MAXN];
long long f[MAXN], g[MAXN], h[MAXN][2];
void init(int &n, vector<int> *e) {
  for (int i = 1; i < n; ++i) {
    int first, second;
    scanf("%d%d", &first, &second);
    e[first].push_back(second), e[second].push_back(first);
  }
}
void Vis1(int first, int fa, vector<int> *e) {
  size[first] = 1;
  for (int i = 0; i < (int)e[first].size(); ++i)
    if (e[first][i] != fa)
      Vis1(e[first][i], first, e),
          f[first] += f[e[first][i]] + size[e[first][i]],
          size[first] += size[e[first][i]];
}
int n, na, nb;
long long Add;
void Vis2(int first, int fa, vector<int> *e) {
  if (fa) Add += (long long)size[first] * (n - size[first]);
  for (int i = 0; i < (int)e[first].size(); ++i)
    if (e[first][i] != fa)
      g[e[first][i]] = g[first] - size[e[first][i]] + (n - size[e[first][i]]),
      Vis2(e[first][i], first, e);
}
long long Mashiro, sum, pdt;
void Vis3(int first, int fa, vector<int> *e) {
  h[first][0] = (long long)na * (g[first]);
  h[first][1] = (long long)nb * (g[first]);
  long long ma1 = h[first][0], ma2 = 0, mb1 = h[first][1], mb2 = 0;
  int ra = first, rb = first;
  for (int i = 0; i < (int)e[first].size(); ++i)
    if (e[first][i] != fa) {
      int second = e[first][i];
      Vis3(second, first, e);
      h[first][0] = max(h[first][0], h[second][0] + pdt);
      h[first][1] = max(h[first][1], h[second][1] + pdt);
      if (ma1 < h[second][0] + pdt)
        ma2 = ma1, ma1 = h[second][0] + pdt, ra = second;
      else if (ma2 < h[second][0] + pdt)
        ma2 = h[second][0] + pdt;
      if (mb1 < h[second][1] + pdt)
        mb2 = mb1, mb1 = h[second][1] + pdt, rb = second;
      else if (mb2 < h[second][1] + pdt)
        mb2 = h[second][1] + pdt;
    }
  if (ra != rb)
    Mashiro = max(Mashiro, ma1 + mb1);
  else
    Mashiro = max(Mashiro, max(ma1 + mb2, ma2 + mb1));
}
pair<long long, long long> solve(int N, vector<int> *e, int Na, int Nb) {
  n = N, sum = Na + Nb, pdt = (long long)Na * Nb;
  na = Na, nb = Nb;
  memset(f, 0, sizeof(f));
  memset(g, 0, sizeof(g));
  memset(h, 0, sizeof(h));
  Vis1(1, 0, e);
  g[1] = f[1];
  Add = 0;
  Vis2(1, 0, e);
  Mashiro = 0;
  Vis3(1, 0, e);
  long long Tohka = 0;
  for (int i = 1; i <= n; ++i) Tohka = max(Tohka, g[i] * (sum));
  Tohka += Add, Mashiro += Add;
  return make_pair(Mashiro + pdt * 2 + (long long)n * sum, Tohka);
}
int main() {
  cin >> n1 >> n2 >> n3;
  init(n1, e1);
  init(n2, e2);
  init(n3, e3);
  pair<long long, long long> w1 = solve(n1, e1, n2, n3),
                             w2 = solve(n2, e2, n1, n3),
                             w3 = solve(n3, e3, n1, n2);
  long long Tohka = max(
      max(w1.first + w2.second + w3.second, w1.second + w2.first + w3.second),
      w1.second + w2.second + w3.first);
  cout << Tohka << endl;
  fclose(stdin);
  fclose(stdout);
  return 0;
}
