#include <bits/stdc++.h>
using namespace std;
const double PI = 4 * atan(1);
int N, K;
int maxl;
vector<int> adj[4003];
long long C1[40], C2[40];
long long* C;
long long dp[4003][40];
long long dpp[4003][40];
long long dp2[4003][40];
long long temp[4003][40];
void nap(long long* A, long long* B) {
  B[0] = A[0];
  assert(B[0] == 1);
  for (int i = 0; i <= maxl; i++)
    for (int j = 1; i + j <= maxl; j++)
      B[i + j] = (B[i + j] + B[i] * A[j]) % 998244353;
}
void dfs_down(int n, int p) {
  dp[n][0] = 1;
  for (int v : adj[n])
    if (v != p) {
      dfs_down(v, n);
      for (int k = 1; k <= maxl; k++)
        dp[n][k] = (dp[n][k] + dpp[v][k - 1]) % 998244353;
    }
  nap(dp[n], dpp[n]);
}
void dfs_up(int n, int p) {
  if (p != -1) {
    temp[n][0] = 1;
    for (int k = 1; k <= maxl; k++)
      temp[n][k] =
          (dp2[p][k] + dp[p][k] - dpp[n][k - 1] + 998244353) % 998244353;
    nap(temp[n], dp2[n]);
    for (int k = maxl; k >= 0; k--) dp2[n][k] = k ? dp2[n][k - 1] : 0;
  }
  for (int v : adj[n])
    if (v != p) {
      dfs_up(v, n);
    }
}
void solve() {
  memset(dp, 0, sizeof dp);
  memset(dpp, 0, sizeof dpp);
  memset(temp, 0, sizeof temp);
  memset(dp2, 0, sizeof dp2);
  dfs_down(0, -1);
  dfs_up(0, -1);
  memset(dpp, 0, sizeof dpp);
  for (int i = 0; i < N; i++) {
    for (int k = 0; k <= maxl; k++) dp[i][k] += dp2[i][k];
    nap(dp[i], dpp[i]);
    for (int k = 0; k <= maxl; k++) C[k] = (C[k] + dpp[i][k]) % 998244353;
  }
}
inline long long mpow(long long a, long long b) {
  return b ? mpow((a * a) % 998244353, b >> 1) * (b % 2 ? a : 1) % 998244353
           : 1;
}
inline long long minv(long long n) { return mpow(n, 998244353 - 2); }
long long binom(int n, int k) {
  long long ret = 1;
  for (int i = 1; i <= k; i++) {
    ret = (ret * (n - i + 1)) % 998244353;
    ret = (ret * minv(i)) % 998244353;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N1, N2;
  cin >> N1 >> N2 >> K;
  if (K % 2) {
    cout << 0 << endl;
    return 0;
  }
  maxl = K / 2;
  N = N1, C = C1;
  for (int i = 1; i < N; i++) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  solve();
  for (int i = 0; i < N; i++) adj[i].clear();
  N = N2, C = C2;
  for (int i = 1; i < N; i++) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  solve();
  long long ans = 0;
  for (int i = 0; i <= maxl; i++) {
    long long cur = binom(K, 2 * i);
    cur = (cur * C2[i]) % 998244353;
    cur = (cur * C1[maxl - i]) % 998244353;
    ans = (ans + cur) % 998244353;
  }
  cout << ans << endl;
  return 0;
}
