#include <bits/stdc++.h>
using namespace std;
const int maxn = 4005, maxe = maxn * 2, maxk = 80, P = 998244353;
int n1, n2, n, K;
int fir[maxn], nxt[maxe], son[maxe], tot = 1;
void add(int x, int y) {
  son[++tot] = y;
  nxt[tot] = fir[x];
  fir[x] = tot;
}
int allsz, Maxsz, nowG, sz[maxn];
bool vis[maxn];
void dfsG(int x, int pre) {
  sz[x] = 1;
  int _max = 0;
  for (int j = fir[x]; j; j = nxt[j])
    if (son[j] != pre && !vis[son[j]])
      dfsG(son[j], x), sz[x] += sz[son[j]], _max = max(_max, sz[son[j]]);
  if (max(allsz - sz[x], _max) < Maxsz)
    nowG = x, Maxsz = max(allsz - sz[x], _max);
}
int getG(int x, int sz_x) {
  allsz = sz_x;
  Maxsz = 1e9;
  dfsG(x, 0);
  return nowG;
}
int v[maxn], id[maxn];
int ans[2][maxn], f[maxn][maxk], g[maxn][maxk];
vector<int> Con[maxn];
void dfs_info(int x, int pre) {
  sz[x] = 1;
  v[++v[0]] = x;
  id[x] = v[0];
  for (int i = 0; i <= K; i++) f[id[x]][i] = g[id[x]][i] = 0;
  Con[id[x]].clear();
  if (pre) Con[id[x]].push_back(id[pre]);
  for (int j = fir[x]; j; j = nxt[j])
    if (son[j] != pre && !vis[son[j]]) {
      sz[x] += sz[son[j]], dfs_info(son[j], x);
      Con[id[x]].push_back(id[son[j]]);
    }
}
void Divide(int G, int _typ) {
  v[0] = 0;
  dfs_info(G, 0);
  f[1][0] = g[1][0] = 1;
  for (int j = 1; j <= K; j++) {
    for (int i = 1; i <= v[0]; i++) {
      for (int k = 0; k < Con[i].size(); k++)
        (f[i][j] += f[Con[i][k]][j - 1]) %= P;
      if (i > 1)
        for (int k = 0; k < Con[i].size(); k++)
          (g[i][j] += g[Con[i][k]][j - 1]) %= P;
    }
  }
  for (int i = 0; i <= K; i++) (ans[_typ][i] += f[1][i]) %= P;
  for (int x = 2; x <= v[0]; x++)
    for (int i = 0; i <= K; i++)
      for (int j = 0; i + j <= K; j++)
        (ans[_typ][i + j] += (long long)f[x][i] * g[x][j] % P) %= P;
  vis[G] = true;
  for (int j = fir[G]; j; j = nxt[j])
    if (!vis[son[j]]) Divide(getG(son[j], sz[son[j]]), _typ);
}
long long fac[maxk], fac_inv[maxk], inv[maxk];
long long C(int n, int m) {
  return fac[n] * fac_inv[m] % P * fac_inv[n - m] % P;
}
int allans;
int main() {
  scanf("%d%d%d", &n1, &n2, &K);
  fac[0] = 1;
  for (int i = 1; i <= K; i++) fac[i] = fac[i - 1] * i % P;
  inv[1] = 1;
  for (int i = 2; i <= K; i++) inv[i] = (long long)(P - P / i) * inv[P % i] % P;
  fac_inv[0] = 1;
  for (int i = 1; i <= K; i++) fac_inv[i] = fac_inv[i - 1] * inv[i] % P;
  for (int i = 1; i <= n1 - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  Divide(getG(1, n1), 0);
  memset(fir, 0, sizeof(fir));
  tot = 1;
  for (int i = 1; i <= n2 - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  memset(vis, 0, sizeof(vis));
  Divide(getG(1, n2), 1);
  for (int i = 0; i <= K; i++)
    (allans += (long long)ans[0][i] * ans[1][K - i] % P * C(K, i) % P) %= P;
  printf("%d\n", allans);
  return 0;
}
