#include <bits/stdc++.h>
using namespace std;
const int N = 4010, K = 80;
const int p = 998244353;
int n1, n2, k, px[2][N], py[2][N], a1[K], a2[K], fac[K], inv[K], f[2][N];
int tot, fi[N], a[N << 1], ne[N << 1], cnt;
inline void A(int &x, int y) { x = (x + y >= p ? x + y - p : x + y); }
inline int C(int x, int y) {
  return 1ll * fac[x] * inv[y] % p * inv[x - y] % p;
}
inline void Add(int x, int y) {
  a[++tot] = y;
  ne[tot] = fi[x];
  fi[x] = tot;
}
inline void Dfs(int x, int fa, int ty) {
  for (int i = fi[x]; i; i = ne[i])
    if (a[i] != fa) {
      ++cnt;
      px[ty][cnt] = x;
      py[ty][cnt] = a[i];
      px[!ty][cnt] = a[i];
      py[!ty][cnt] = x;
      Dfs(a[i], x, !ty);
    }
}
inline void Solve(int n, int k, int ans[]) {
  tot = 0;
  memset(fi + 1, 0, n * sizeof *fi);
  for (int i = 1, x, y; i < n; ++i) {
    scanf("%d%d", &x, &y);
    Add(x, y);
    Add(y, x);
  }
  ans[0] = n;
  for (int x = 1; x <= n; ++x) {
    cnt = 0;
    Dfs(x, 0, 1);
    memset(f[0] + 1, 0, n * sizeof *f[0]);
    f[0][x] = 1;
    for (int len = 1; len <= k; ++len) {
      memset(f[len & 1] + 1, 0, n * sizeof *f[len & 1]);
      for (int i = 1; i < n; ++i)
        A(f[len & 1][py[len & 1][i]], f[~len & 1][px[len & 1][i]]);
      A(ans[len], f[len & 1][x]);
    }
  }
}
int main() {
  scanf("%d%d%d", &n1, &n2, &k);
  Solve(n1, k, a1);
  Solve(n2, k, a2);
  fac[0] = 1;
  for (int i = 1; i < K; ++i) fac[i] = 1ll * fac[i - 1] * i % p;
  inv[0] = inv[1] = 1;
  for (int i = 2; i < K; ++i) inv[i] = 1ll * inv[p % i] * (p - p / i) % p;
  for (int i = 2; i < K; ++i) inv[i] = 1ll * inv[i - 1] * inv[i] % p;
  int ans = 0;
  for (int i = 0; i <= k; ++i)
    ans = (ans + 1ll * C(k, i) * a1[i] % p * a2[k - i]) % p;
  printf("%d\n", ans);
  return 0;
}
