#include <bits/stdc++.h>
using namespace std;
const int N = 10100, MOD = 998244353;
inline int Add(int x, int y) {
  x += y;
  if (x >= MOD) x -= MOD;
  return x;
}
inline int Dec(int x, int y) {
  x -= y;
  if (x < 0) x += MOD;
  return x;
}
inline int Mul(int x, int y) { return 1LL * x * y % MOD; }
inline int Kissme(int x, int y) {
  int c = 1;
  while (y) {
    if (y & 1) c = Mul(c, x);
    x = Mul(x, x);
    y >>= 1;
  }
  return c;
}
int fac[N], inv[N], ans1[N], ans2[N], s[N][80], n1, n2, K, id[4010][4010];
vector<int> g[N], f[N][80];
void Pre(void) {
  fac[0] = 1;
  int lim = N - 10;
  for (int i = 1; i <= lim; i++) fac[i] = Mul(fac[i - 1], i);
  inv[lim] = Kissme(fac[lim], MOD - 2);
  for (int i = lim - 1; i >= 0; i--) inv[i] = Mul(inv[i + 1], i + 1);
}
int C(int x, int y) { return Mul(fac[x], Mul(inv[y], inv[x - y])); }
void Solve(int n, int *a) {
  for (int i = 1; i <= n; i++) g[i].clear(), g[i].push_back(0);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < g[i].size(); j++) id[i][g[i][j]] = j;
  memset(s, 0, sizeof(s));
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= K; j++) f[i][j].clear(), f[i][j].resize(g[i].size());
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < g[i].size(); j++) {
      f[i][0][j] = 1;
      if (j) s[g[i][j]][0]++;
    }
  a[0] = n;
  for (int i = 2; i <= K; i++) {
    for (int j = 1; j <= n; j++) {
      for (int l = 0; l < g[j].size(); l++) {
        for (int t = 0; t <= i - 2; t += 2) {
          int S = Dec(s[j][t], l ? f[g[j][l]][t][id[g[j][l]][j]] : 0);
          f[j][i][l] = Add(f[j][i][l], Mul(S, f[j][i - t - 2][l]));
        }
        if (l) s[g[j][l]][i] = Add(s[g[j][l]][i], f[j][i][l]);
      }
      a[i] = Add(a[i], f[j][i][0]);
    }
  }
}
int main(void) {
  scanf("%d%d%d", &n1, &n2, &K);
  if (K & 1) return puts("0"), 0;
  Pre();
  Solve(n1, ans1);
  Solve(n2, ans2);
  int ans = 0;
  for (int i = 0; i <= K; i += 2)
    ans = Add(ans, Mul(ans1[i], Mul(ans2[K - i], C(K, i))));
  cout << ans << endl;
}
