#include <bits/stdc++.h>
using namespace std;
struct _vertex {
  long long D;
  int navs_dfs_D;
  vector<int> sousedi;
};
int n[3];
_vertex strom[3][1100];
long long vzdalenosti[3][1100][1100];
long long maxvz[3];
pair<long long, int> dfs_D(int a, int r, int v, long long vz = 0) {
  pair<long long, int> ret, gt;
  ret.first = 0;
  ret.second = 1;
  strom[a][v].navs_dfs_D = r;
  vzdalenosti[a][r][v] = vz;
  for (int i = 0; i < strom[a][v].sousedi.size(); i++) {
    int w = strom[a][v].sousedi[i];
    if (strom[a][w].navs_dfs_D != r) {
      gt = dfs_D(a, r, w, vz + 1);
      ret.first += gt.first + gt.second;
      ret.second += gt.second;
    }
  }
  return ret;
}
int main() {
  int x, y;
  long long constsum = 0;
  for (int a = 0; a < 3; a++) {
    scanf("%d", &n[a]);
    maxvz[a] = 0;
  }
  for (int a = 0; a < 3; a++) {
    for (int i = 0; i < n[a] - 1; i++) {
      scanf("%d%d", &x, &y);
      x--;
      y--;
      strom[a][x].sousedi.push_back(y);
      strom[a][y].sousedi.push_back(x);
    }
    for (int i = 0; i < n[a]; i++) {
      strom[a][i].navs_dfs_D = -1;
    }
    for (int i = 0; i < n[a]; i++) {
      strom[a][i].D = dfs_D(a, i, i).first;
      maxvz[a] = max(maxvz[a], strom[a][i].D);
      constsum += strom[a][i].D;
    }
  }
  long long maxsum = 0, sum;
  for (int Y = 0; Y < 3; Y++) {
    int X = (Y + 1) % 3;
    int Z = (Y + 2) % 3;
    long long maxpsum = 0;
    int maxy1, maxy2;
    long long psum;
    for (int y1 = 0; y1 < n[Y]; y1++) {
      for (int y2 = 0; y2 < n[Y]; y2++) {
        psum = n[X] * strom[Y][y1].D + n[Z] * strom[Y][y2].D +
               n[X] * n[Z] * vzdalenosti[Y][y1][y2];
        if (psum > maxpsum) {
          maxpsum = psum;
          maxy1 = y1;
          maxy2 = y2;
        }
      }
    }
    sum = constsum / 2 + maxpsum + n[X] * n[Y] + n[Y] * n[Z] + 2 * n[X] * n[Z] +
          n[Y] * maxvz[X] + n[Y] * maxvz[Z] + n[Z] * maxvz[X] + n[X] * maxvz[Z];
    maxsum = max(maxsum, sum);
  }
  printf("%I64d", maxsum);
}
