#include <bits/stdc++.h>
int ways[37 * 2 + 1][37 * 2 + 1], k;
void init() {
  int i, j;
  ways[0][0] = 1;
  for (i = 0; i <= k * 2; i++)
    for (j = 0; j <= k * 2; j++)
      ways[i][j] =
          i == 0 || j == 0 ? 1 : (ways[i - 1][j] + ways[i][j - 1]) % 998244353;
}
int oo[1 + (4000 - 1) * 4], oj[1 + (4000 - 1) * 4];
int link(int o, int j) {
  static int _ = 1;
  oo[_] = o, oj[_] = j;
  return _++;
}
int *ae, *xx, dp[4000][37 + 1], dq[4000][37 + 1];
void dfs(int p, int i) {
  int o, l, c;
  memset(dq[i], 0, (k + 1) * sizeof *dq[i]);
  for (o = ae[i]; o; o = oo[o]) {
    int j = oj[o];
    if (j != p) {
      dfs(i, j);
      for (l = 0; l <= k; l++) dq[i][l] = (dq[i][l] + dp[j][l]) % 998244353;
    }
  }
  xx[0] = (xx[0] + 1) % 998244353;
  memset(dp[i], 0, (k + 1) * sizeof *dp[i]), dp[i][0] = 1;
  for (l = 1; l <= k; l++)
    for (c = 1; c <= l; c++) {
      int x = (long long)dq[i][c - 1] * dp[i][l - c] % 998244353;
      dp[i][l] = (dp[i][l] + x) % 998244353;
      xx[l] = (xx[l] + (long long)x * c * 2) % 998244353;
    }
}
int main() {
  static int ae1[4000], xx1[37 + 1], ae2[4000], xx2[37 + 1];
  int n1, n2, h, i, j, l, ans;
  scanf("%d%d%d", &n1, &n2, &k);
  if (k % 2 != 0) {
    printf("0\n");
    return 0;
  }
  k /= 2;
  init();
  for (h = 0; h < n1 - 1; h++) {
    scanf("%d%d", &i, &j), i--, j--;
    ae1[i] = link(ae1[i], j), ae1[j] = link(ae1[j], i);
  }
  for (h = 0; h < n2 - 1; h++) {
    scanf("%d%d", &i, &j), i--, j--;
    ae2[i] = link(ae2[i], j), ae2[j] = link(ae2[j], i);
  }
  ae = ae1, xx = xx1, dfs(-1, 0);
  ae = ae2, xx = xx2, dfs(-1, 0);
  ans = 0;
  for (l = 0; l <= k; l++) {
    assert(xx1[l] > 0);
    ans = (ans + (long long)xx1[l] * xx2[k - l] % 998244353 *
                     ways[l * 2][(k - l) * 2]) %
          998244353;
  }
  printf("%d\n", ans);
  return 0;
}
