#include <bits/stdc++.h>
using namespace std;
inline int max(int a, int b) { return a < b ? b : a; }
inline int min(int a, int b) { return a > b ? b : a; }
inline long long max(long long a, long long b) { return a < b ? b : a; }
inline long long min(long long a, long long b) { return a > b ? b : a; }
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const long long INF = 1e18;
long long n[3], p[3];
vector<int> G[3][N];
long long sum[3][N], c[3][N], mx[3][N][2];
int zz[3][N];
void dfs1(int v, int p, int n) {
  c[n][v]++;
  for (int i = 0; i < G[n][v].size(); ++i) {
    int to = G[n][v][i];
    if (to != p) {
      dfs1(to, v, n);
      c[n][v] += c[n][to];
      sum[n][v] += sum[n][to] + c[n][to];
    }
  }
}
void dfs2(int v, int p, int m, long long x) {
  sum[m][v] += x;
  for (int i = 0; i < G[m][v].size(); ++i) {
    int to = G[m][v][i];
    if (to != p) {
      dfs2(to, v, m, sum[m][v] - (sum[m][to] + c[m][to]) + n[m] - c[m][to]);
    }
  }
}
long long n1, n2;
void dfs3(int v, int p, int m) {
  mx[m][v][0] = n1 * sum[m][v];
  mx[m][v][1] = 0;
  zz[m][v] = v;
  for (int i = 0; i < G[m][v].size(); ++i) {
    int to = G[m][v][i];
    if (to != p) {
      dfs3(to, v, m);
      long long x = mx[m][to][0] + n1 * n2;
      if (x > mx[m][v][0]) {
        mx[m][v][1] = mx[m][v][0];
        mx[m][v][0] = x;
        zz[m][v] = to;
      } else
        mx[m][v][1] = max(x, mx[m][v][1]);
    }
  }
}
void dfs4(int v, int p, int m, long long x) {
  mx[m][v][0] = max(mx[m][v][0], x);
  for (int i = 0; i < G[m][v].size(); ++i) {
    int to = G[m][v][i];
    if (to != p) {
      long long y =
          max(((zz[m][v] == to) ? mx[m][v][1] : mx[m][v][0]), x) + n1 * n2;
      dfs4(to, v, m, y);
    }
  }
}
long long calc() {
  long long ans = 0, s = 0;
  for (int i = 0; i < n[p[1]]; ++i) s = max(s, sum[p[1]][i]);
  ans += (n[p[0]] + n[p[2]]) * (s + n[p[1]]);
  s = 0;
  for (int i = 0; i < n[p[2]]; ++i) s = max(s, sum[p[2]][i]);
  ans += (n[p[0]] + n[p[1]]) * (s + n[p[2]]);
  n1 = n[p[1]], n2 = n[p[2]];
  int cur = p[0];
  dfs3(0, -1, cur);
  dfs4(0, -1, cur, 0);
  s = 0;
  for (int i = 0; i < n[cur]; ++i) {
    long long x = mx[cur][i][0] + n2 * sum[cur][i];
    s = max(s, x);
  }
  return ans + s;
}
int main() {
  scanf("%lld%lld%lld", &n[0], &n[1], &n[2]);
  for (int k = 0; k < 3; ++k)
    for (int i = 0; i < n[k] - 1; ++i) {
      int x;
      int y;
      scanf("%d%d", &x, &y);
      x--;
      y--;
      G[k][x].push_back(y);
      G[k][y].push_back(x);
    }
  for (int k = 0; k < 3; ++k) {
    dfs1(0, -1, k);
    dfs2(0, -1, k, 0);
  }
  long long ans = 0, sum1 = 0;
  for (int k = 0; k < 3; ++k)
    for (int i = 0; i < n[k]; ++i) ans += sum[k][i];
  for (int i = 0; i < 3; ++i) p[i] = i;
  ans /= 2;
  for (int k = 0; k < 3; ++k) {
    swap(p[k], p[0]);
    sum1 = max(sum1, calc());
    swap(p[k], p[0]);
  }
  ans += sum1;
  printf("%lld\n", ans);
  return 0;
}
