#include <bits/stdc++.h>
using namespace std;
typedef long long arr[4][100050];
arr Down, Up, Cnt, H;
vector<int> a[4][100050];
long long DA[100050], DB[100050], n[4];
void DFS1(int u, int pre, int pos) {
  Down[pos][u] = 0;
  Cnt[pos][u] = 1;
  for (int i = 0; i < a[pos][u].size(); i++) {
    int v = a[pos][u][i];
    if (v == pre) continue;
    H[pos][v] = H[pos][u] + 1;
    DFS1(v, u, pos);
    Cnt[pos][u] += Cnt[pos][v];
    Down[pos][u] += Down[pos][v] + Cnt[pos][v];
  }
}
void DFS2(int u, int pre, int pos) {
  for (int i = 0; i < a[pos][u].size(); i++) {
    int v = a[pos][u][i];
    if (v == pre) continue;
    Up[pos][v] = Up[pos][u] + Down[pos][u] - Down[pos][v] - Cnt[pos][v] +
                 (n[pos] - Cnt[pos][v]);
    DFS2(v, u, pos);
  }
}
void DFS3(int u, int pre, int pos, int A, int B, long long &Max) {
  DA[u] = (Up[pos][u] + Down[pos][u]) * A + H[pos][u] * A * B;
  DB[u] = (Up[pos][u] + Down[pos][u]) * B + H[pos][u] * A * B;
  for (int i = 0; i < a[pos][u].size(); i++) {
    int v = a[pos][u][i];
    if (v == pre) continue;
    DFS3(v, u, pos, A, B, Max);
    long long Total = max(DA[u] + DB[v], DB[u] + DA[v]) - H[pos][u] * A * B * 2;
    Max = max(Max, Total);
    DA[u] = max(DA[u], DA[v]);
    DB[u] = max(DB[u], DB[v]);
  }
}
long long Solve(int p1, int p2, int p3) {
  long long res = 0;
  DFS1(1, 0, p1);
  DFS1(1, 0, p2);
  DFS1(1, 0, p3);
  DFS2(1, 0, p1);
  DFS2(1, 0, p2);
  DFS2(1, 0, p3);
  for (int i = 1; i <= n[p1]; i++) res += Down[p1][i] + Up[p1][i];
  for (int i = 1; i <= n[p2]; i++) res += Down[p2][i] + Up[p2][i];
  for (int i = 1; i <= n[p3]; i++) res += Down[p3][i] + Up[p3][i];
  res /= 2;
  res += n[p2] * (n[p1] + n[p3]) + n[p1] * n[p3] * 2;
  long long Max = 0;
  for (int i = 1; i <= n[p1]; i++) Max = max(Max, Down[p1][i] + Up[p1][i]);
  res += Max * (n[p2] + n[p3]);
  Max = 0;
  for (int i = 1; i <= n[p3]; i++) Max = max(Max, Down[p3][i] + Up[p3][i]);
  res += Max * (n[p2] + n[p1]);
  Max = 0;
  DFS3(1, 0, p2, n[p1], n[p3], Max);
  res += Max;
  return res;
}
void Read(int p) {
  int u, v;
  for (int i = 1; i < n[p]; i++) {
    cin >> u >> v;
    a[p][u].push_back(v);
    a[p][v].push_back(u);
  }
}
int main() {
  cin >> n[1] >> n[2] >> n[3];
  Read(1);
  Read(2);
  Read(3);
  long long ans = max(max(Solve(1, 2, 3), Solve(2, 1, 3)), Solve(1, 3, 2));
  cout << ans;
}
