#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)2e5 + 5;
struct TREE {
  int n, sz[maxn], bg[maxn], ed[maxn], N, h[maxn], lg2[maxn], mn[maxn][18], T2,
      T3;
  long long sum = 0, tmp = 0, res = 0, D[maxn];
  pair<int, int> cand[maxn];
  vector<int> G[maxn];
  void input() {
    for (int i = 1; i < n; i++) {
      int u, v;
      cin >> u >> v;
      G[u].push_back(v);
      G[v].push_back(u);
    }
  }
  void dfs(int u, int p) {
    sz[u] = 1;
    mn[++N][0] = h[u];
    bg[u] = ed[u] = N;
    for (auto v : G[u])
      if (v != p) {
        h[v] = h[u] + 1;
        dfs(v, u);
        sz[u] += sz[v];
        mn[++N][0] = h[u];
        ed[u] = N;
      }
    if (p != -1) sum += 1LL * sz[u] * (n - sz[u]), D[1] += sz[u];
  }
  void redfs(int u, int p) {
    if (p != -1) D[u] = D[p] + n - 2 * sz[u];
    for (auto v : G[u])
      if (v != p) redfs(v, u);
  }
  int dist(int u, int v) {
    if (bg[u] > bg[v]) swap(u, v);
    int l = bg[u], r = ed[v], k = lg2[r - l + 1];
    return h[u] + h[v] - 2 * min(mn[l][k], mn[r - (1 << k) + 1][k]);
  }
  long long f(int u, int v) {
    return D[u] * T2 + D[v] * T3 + 1LL * (dist(u, v) + 2) * T2 * T3;
  }
  void calc(int u, int p) {
    cand[u] = pair<int, int>(u, -1);
    for (auto v : G[u])
      if (v != p) {
        calc(v, u);
        if (cand[u].second == -1 || f(u, cand[u].second) < f(u, cand[v].first))
          cand[u].second = cand[v].first;
        if (f(u, cand[u].second) > f(u, cand[u].first))
          swap(cand[u].first, cand[u].second);
      }
  }
  void modify(int u, int p) {
    if (p != -1) {
      int v = cand[p].first;
      if (v != cand[u].first && v != cand[u].second) {
        if (f(u, cand[u].first) <= f(u, v)) {
          swap(cand[u].first, cand[u].second);
          cand[u].first = v;
        } else if (f(u, cand[u].second) <= f(u, v))
          cand[u].second = v;
      }
      v = cand[p].second;
      if (v != cand[u].first && v != cand[u].second) {
        if (f(u, cand[u].first) <= f(u, v)) {
          swap(cand[u].first, cand[u].second);
          cand[u].first = v;
        } else if (f(u, cand[u].second) <= f(u, v))
          cand[u].second = v;
      }
    }
    for (auto x : G[u])
      if (x != p) modify(x, u);
  }
  void solve() {
    dfs(1, -1);
    redfs(1, -1);
    for (int i = 1; i <= N; i++) lg2[i] = log2(i);
    for (int k = 1; (1 << k) <= N; k++)
      for (int i = 1; i + (1 << k) - 1 <= N; i++) {
        mn[i][k] = min(mn[i][k - 1], mn[i + (1 << k - 1)][k - 1]);
      }
    calc(1, -1);
    modify(1, -1);
    for (int i = 1; i <= n; i++) {
      res = max(res, f(i, cand[i].first));
      assert(cand[i].first != cand[i].second);
      tmp = max(tmp, D[i] * (T2 + T3));
    }
    res += 1LL * n * (T2 + T3);
  }
};
TREE A, B, C;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> A.n >> B.n >> C.n;
  A.T2 = B.n, A.T3 = C.n;
  B.T2 = A.n, B.T3 = C.n;
  C.T2 = B.n, C.T3 = A.n;
  A.input();
  B.input();
  C.input();
  A.solve();
  B.solve();
  C.solve();
  long long ans = max(A.res + B.tmp + C.tmp,
                      max(A.tmp + B.res + C.tmp, A.tmp + B.tmp + C.res));
  ans += A.sum + B.sum + C.sum;
  cout << ans << '\n';
}
