#include <bits/stdc++.h>
using namespace std;
const int maxn = 4000, mod = 998244353;
int k;
int ans;
int C[80][80];
void inc(int &a, int b) { a = (a + b) % mod; }
struct wjmzbmr {
  int n;
  vector<int> g[maxn + 5];
  vector<int> dp[80][maxn + 5];
  int sum[80][maxn + 5];
  int ans[maxn + 5], sz[maxn + 5];
  map<pair<int, int>, int> s;
  void init() {
    for (int i = 1; i < n; ++i) {
      int u, v;
      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 = 0; j < g[i].size(); ++j) s[make_pair(i, g[i][j])] = j;
    for (int i = 1; i <= n; ++i) sz[i] = g[i].size(), g[i].push_back(0);
    for (int t = 0; t <= k; ++t)
      for (int i = 0; i <= n; ++i) dp[t][i].resize(sz[i] + 1, 0);
  }
  void work() {
    for (int i = 1; i <= n; ++i)
      for (int j = 0; j <= sz[i]; ++j) {
        dp[0][i][j] = 1;
        inc(sum[0][g[i][j]], 1);
      }
    for (int i = 2; i <= k; ++i)
      for (int u = 1; u <= n; ++u)
        for (int j = 0; j <= sz[u]; ++j) {
          int v;
          if (j < sz[u])
            v = g[u][j];
          else
            v = 0;
          int id;
          if (v == 0)
            id = 0;
          else
            id = s[make_pair(v, u)];
          for (int t = 0; t <= i - 2; ++t)
            dp[i][u][j] =
                ((dp[i][u][j] + 1LL * dp[i - t - 2][u][j] *
                                    (sum[t][u] - dp[t][v][id]) % mod) %
                     mod +
                 mod) %
                mod;
          inc(sum[i][v], dp[i][u][j]);
        }
    for (int i = 0; i <= k; i += 2)
      for (int u = 1; u <= n; ++u) inc(ans[i], dp[i][u][sz[u]]);
  }
} tree[2];
int main() {
  scanf("%d%d%d", &tree[0].n, &tree[1].n, &k);
  tree[0].init(), tree[1].init();
  tree[0].work();
  tree[1].work();
  C[0][0] = 1;
  for (int i = 1; i <= k; ++i) {
    C[i][0] = 1;
    for (int j = 1; j <= i; ++j)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
  }
  for (int i = 0; i <= k; ++i)
    inc(ans,
        int(1LL * tree[0].ans[i] * tree[1].ans[k - i] % mod * C[k][i] % mod));
  printf("%d\n", ans);
  return 0;
}
