#include <bits/stdc++.h>
using namespace std;
long long n[10];
vector<long long> g[10][2000];
long long a, b;
long long arp[200][2000];
long long subdist[200][2000];
long long dst[4][2000][2000];
long long tcost[2000];
long long tans;
long long ans;
void read() {
  cin >> n[1] >> n[2] >> n[3];
  for (int i = 1; i <= 3; i++) {
    for (int j = 1; j < n[i]; j++) {
      cin >> a >> b;
      g[i][a].push_back(b);
      g[i][b].push_back(a);
    }
  }
}
void dfs(long tr, long v) {
  for (int i = 0; i < g[tr][v].size(); i++) {
    long q = g[tr][v][i];
    if (arp[tr][q]) continue;
    arp[tr][q] = arp[tr][v] + 1;
    dfs(tr, q);
  }
}
void calcsubd() {
  for (int i = 1; i <= 3; i++) {
    for (int tv = 1; tv <= n[i]; tv++) {
      for (int j = 1; j <= n[i]; j++) arp[i][j] = 0;
      arp[i][tv] = 1;
      dfs(i, tv);
      for (int j = 1; j <= n[i]; j++) subdist[i][tv] += arp[i][j] - 1;
      for (int j = 1; j <= n[i]; j++) dst[i][tv][j] = arp[i][j] - 1;
      tcost[i] += subdist[i][tv];
    }
  }
}
void solve(long ltree, long cntr, long rtree) {
  long long bls, brs;
  bls = brs = 0;
  for (int i = 1; i <= n[ltree]; i++) bls = max(bls, subdist[ltree][i]);
  for (int i = 1; i <= n[rtree]; i++) brs = max(brs, subdist[rtree][i]);
  tans = 0;
  tans += tcost[1] + tcost[2] + tcost[3];
  for (int i = 1; i <= n[cntr]; i++)
    for (int j = 1; j <= n[cntr]; j++) {
      long long qtans = tans;
      tans += subdist[cntr][i] * n[ltree] + bls * n[cntr] + n[ltree] * n[cntr];
      tans += subdist[cntr][j] * n[rtree] + brs * n[cntr] + n[rtree] * n[cntr];
      tans += 2 * n[ltree] * n[rtree] + dst[cntr][i][j] * n[ltree] * n[rtree] +
              bls * n[rtree] + brs * n[ltree];
      ans = max(ans, tans);
      tans = qtans;
    }
}
int main() {
  ios_base::sync_with_stdio(0);
  read();
  calcsubd();
  ans = 0;
  for (int i = 1; i <= 3; i++) tcost[i] /= 2;
  solve(1, 2, 3);
  solve(1, 3, 2);
  solve(2, 1, 3);
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
