#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
int n, m, k, i, j, mod = 998244353, sum, fac[8005], inv[8005], first[8005];
int c(int x, int y) {
  return 1ll * fac[x] * first[y] % mod * first[x - y] % mod;
}
void inc(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
}
struct tre {
  vector<int> e[4005];
  int ans[4005], vis[4005], sz[4005], f[4005][85], g[4005][85], dp[4005], rt;
  vector<int> seq;
  void dfs_sz(int x, int fa) {
    sz[x] = 1;
    for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++)
      if (*it != fa && !vis[*it]) {
        dfs_sz(*it, x);
        sz[x] += sz[*it];
      }
  }
  void dfs_rt(int x, int fa, int all) {
    dp[x] = all - sz[x];
    for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++)
      if (*it != fa && !vis[*it]) {
        dfs_rt(*it, x, all);
        dp[x] = max(dp[x], sz[*it]);
      }
    if (rt == -1 || dp[x] < dp[rt]) rt = x;
  }
  void dfs_seq(int x, int fa) {
    seq.push_back(x);
    for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++)
      if (*it != fa && !vis[*it]) {
        dfs_seq(*it, x);
      }
  }
  void solve(int x) {
    dfs_sz(x, 0);
    int all = sz[x];
    rt = -1;
    dfs_rt(x, 0, all);
    x = rt;
    seq.clear();
    dfs_seq(x, 0);
    vis[x] = 1;
    for (__typeof((seq).begin()) it = (seq).begin(); it != (seq).end(); it++) {
      memset((f[*it]), (0), (sizeof((f[*it]))));
      memset((g[*it]), (0), (sizeof((g[*it]))));
    }
    f[x][0] = g[x][0] = 1;
    int i, j;
    for ((i) = (0); (i) <= (k - 1); (i)++) {
      for (__typeof((seq).begin()) it = (seq).begin(); it != (seq).end();
           it++) {
        for (__typeof((e[*it]).begin()) it2 = (e[*it]).begin();
             it2 != (e[*it]).end(); it2++) {
          if (*it2 != x) inc(f[*it2][i + 1], f[*it][i]);
          inc(g[*it2][i + 1], g[*it][i]);
        }
      }
    }
    for (__typeof((seq).begin()) it = (seq).begin(); it != (seq).end(); it++) {
      if (*it == x) {
        for ((i) = (0); (i) <= (k); (i)++) {
          inc(ans[i], g[*it][i]);
        }
        continue;
      }
      for ((i) = (0); (i) <= (k); (i)++)
        for ((j) = (0); (j) <= (k - i); (j)++) {
          ans[i + j] = (ans[i + j] + 1ll * f[*it][i] * g[*it][j]) % mod;
        }
    }
    for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++)
      if (!vis[*it]) solve(*it);
  }
} t1, t2;
int main() {
  fac[0] = fac[1] = inv[1] = first[0] = first[1] = 1;
  for ((i) = (2); (i) <= (8000); (i)++) {
    fac[i] = 1ll * fac[i - 1] * i % mod;
    inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod;
    first[i] = 1ll * first[i - 1] * inv[i] % mod;
  }
  read(n);
  read(m);
  read(k);
  for (((i)) = (1); ((i)) <= ((n - 1)); ((i))++) {
    int x, y;
    read(x);
    read(y);
    t1.e[x].push_back(y);
    t1.e[y].push_back(x);
  }
  for (((i)) = (1); ((i)) <= ((m - 1)); ((i))++) {
    int x, y;
    read(x);
    read(y);
    t2.e[x].push_back(y);
    t2.e[y].push_back(x);
  }
  t1.solve(1);
  t2.solve(1);
  for ((i) = (0); (i) <= (k); (i)++) {
    sum = (sum + 1ll * c(k, i) * t1.ans[i] % mod * t2.ans[k - i]) % mod;
  }
  cout << sum << endl;
  return 0;
}
