#include <bits/stdc++.h>
using namespace std;
const int maxn = 4001, mod = 998244353;
vector<int> g[maxn];
int n, m, k, c[80][80];
int sz[maxn], used[maxn];
int dp1[maxn][80], dp2[maxn][80];
int ANS, ans[80], ans1[80], ans2[80];
void add(int &a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
void dfs(int v, int p) {
  sz[v] = 1;
  for (auto to : g[v])
    if (!used[to] && to != p) {
      dfs(to, v);
      sz[v] += sz[to];
    }
}
int getctr(int v, int p, int SZ) {
  for (auto to : g[v])
    if (!used[to] && to != p && sz[to] > SZ / 2) return getctr(to, v, SZ);
  return v;
}
void calc_dp(int v, int p, int len, int ban) {
  for (auto to : g[v])
    if (!used[to]) {
      if (to != p) calc_dp(to, v, len, ban);
      if (to != ban) add(dp1[to][len], dp1[v][len - 1]);
      add(dp2[to][len], dp2[v][len - 1]);
    }
}
void calc_ans(int v, int p) {
  for (int i = 0; i <= k; i++)
    for (int j = 0; j + i <= k; j++)
      add(ans[i + j], 1ll * dp1[v][i] * dp2[v][j] % mod);
  for (auto to : g[v])
    if (!used[to] && to != p) calc_ans(to, v);
}
void solve(int v) {
  dfs(v, v);
  int ctr = getctr(v, v, sz[v]);
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= k; j++) dp1[i][j] = dp2[i][j] = 0;
  dp1[ctr][0] = 1;
  dp2[ctr][0] = 1;
  for (int len = 1; len <= k; len++) calc_dp(ctr, ctr, len, ctr);
  calc_ans(ctr, ctr);
  used[ctr] = 1;
  for (auto to : g[ctr])
    if (!used[to]) solve(to);
}
int main() {
  for (int i = 0; i < 80; i++) c[0][i] = 1;
  for (int i = 1; i < 80; i++)
    for (int j = 1; j <= i; j++)
      c[j][i] = (c[j - 1][i - 1] + c[j][i - 1]) % mod;
  scanf("%d%d%d", &n, &m, &k);
  if (k & 1) cout << 0, exit(0);
  for (int i = 1; i < n; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    g[v].push_back(u);
    g[u].push_back(v);
  }
  solve(1);
  for (int i = 0; i <= k; i++) {
    ans1[i] = ans[i];
    ans[i] = 0;
  }
  n = m;
  for (int i = 0; i < maxn; i++) {
    used[i] = 0;
    g[i].clear();
  }
  for (int i = 1; i < n; i++) {
    int v, u;
    scanf("%d%d", &v, &u);
    g[v].push_back(u);
    g[u].push_back(v);
  }
  solve(1);
  for (int i = 0; i <= k; i++) {
    ans2[i] = ans[i];
    ans[i] = 0;
  }
  for (int i = 0; i <= k; i++)
    add(ANS, 1ll * ans1[i] * ans2[k - i] % mod * c[i][k] % mod);
  cout << ANS;
}
