#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, fu = 0;
  char ch = getchar();
  for (; ch < 48 || ch > 57; ch = getchar()) fu |= (ch == '-');
  for (; ch > 47 && ch < 58; ch = getchar()) x = x * 10 + ch - '0';
  return fu ? -x : x;
}
inline void add_(int &x, const int &y) {
  x += y;
  x = x < 998244353 ? x : x - 998244353;
}
inline int del(int x, const int &y) {
  x -= y;
  return x < 0 ? x + 998244353 : x;
}
int K, ans, fac[80], inv[80];
struct Graph {
  int n, head[4005], eot;
  struct edge {
    int t, nxt;
  } e[8005];
  void add(int u, int v) {
    e[++eot] = (edge){v, head[u]};
    head[u] = eot;
    e[++eot] = (edge){u, head[v]};
    head[v] = eot;
  }
  int f[4005][80], g[4005][80];
  void dfs(int x, int pa) {
    for (int i = head[x]; i; i = e[i].nxt) {
      if (e[i].t == pa) continue;
      dfs(e[i].t, x);
      for (int j = 0; j <= K; j++) add_(f[x][j], g[e[i].t][j]);
    }
    g[x][0] = 1;
    for (int i = 1; i <= K; i++)
      for (int j = 0; j < i; j++)
        add_(g[x][i], (int)(1LL * g[x][j] * f[x][i - j - 1] % 998244353));
  }
  int dp[4005][80], cnt[80];
  void Dfs(int x, int pa) {
    for (int i = head[x]; i; i = e[i].nxt) {
      if (e[i].t == pa) continue;
      for (int j = 0; j <= K; j++) g[x][j] = 0;
      g[x][0] = 1;
      for (int p = 1; p <= K; p++)
        for (int q = 0; q < p; q++)
          add_(g[x][p], (int)(1LL * del(f[x][q], g[e[i].t][q]) *
                              g[x][p - q - 1] % 998244353));
      for (int j = 0; j <= K; j++) add_(f[e[i].t][j], g[x][j]);
      dp[e[i].t][0] = 1;
      for (int p = 1; p <= K; p++)
        for (int q = 0; q < p; q++)
          add_(dp[e[i].t][p],
               (int)(1LL * f[e[i].t][q] * dp[e[i].t][p - q - 1] % 998244353));
      Dfs(e[i].t, x);
    }
  }
  void buildGraph() {
    for (int i = 1, u, v; i < n; i++) u = read(), v = read(), add(u, v);
    dfs(1, 0);
    for (int i = 0; i <= K; i++) dp[1][i] = g[1][i];
    Dfs(1, 0);
    for (int i = 1; i <= n; i++)
      for (int j = 0; j <= K; j++) add_(cnt[j], dp[i][j]);
  }
} t1, t2;
int Q_P(int x, int y) {
  int R = 1;
  for (; y; y >>= 1, x = 1LL * x * x % 998244353)
    if (y & 1) R = 1LL * R * x % 998244353;
  return R;
}
int C(int n, int m) {
  return n < m ? 0 : 1LL * fac[n] * inv[m] % 998244353 * inv[n - m] % 998244353;
}
int main() {
  t1.n = read(), t2.n = read(), K = read();
  if (K & 1) return puts("0"), 0;
  int k = K;
  K >>= 1, fac[0] = 1;
  t1.buildGraph(), t2.buildGraph();
  for (int i = 1; i <= k; i++) fac[i] = 1LL * fac[i - 1] * i % 998244353;
  inv[k] = Q_P(fac[k], 998244353 - 2);
  for (int i = k; i >= 1; i--) inv[i - 1] = 1LL * inv[i] * i % 998244353;
  for (int i = 0; i <= K; i++)
    add_(ans, 1LL * C(k, i << 1) * t1.cnt[i] % 998244353 * t2.cnt[K - i] %
                  998244353);
  printf("%d\n", ans);
  return 0;
}
