#include <bits/stdc++.h>
using namespace std;
const long long NM = 1ll * 998244353 * 998244353 * 6;
int n, m, k, a[2][4005], c[100][100];
long long s[75], t[75], ans, p, q;
int px[4005], qx[4005], py[4005], qy[4005];
bool f, g;
void add1(int &x, int y) {
  x += y;
  if (x >= 998244353) x -= 998244353;
}
void add2(long long &x, long long y) {
  x += y;
  if (x >= NM) x -= NM;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    px[i] = u;
    py[i] = v;
  }
  for (int i = 1; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    qx[i] = u;
    qy[i] = v;
  }
  if (k & 1) {
    cout << 0 << endl;
    return 0;
  }
  c[0][0] = 1;
  for (int i = 1; i <= k; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++)
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 998244353;
  }
  for (int i = 1; i <= n; i++) {
    memset(a, 0, sizeof(a));
    a[0][i] = 1;
    s[0]++;
    for (int j = 1; j <= k / 2; j++) {
      g = j & 1;
      f = !g;
      for (int u = 1; u < n; u++) {
        add1(a[g][py[u]], a[f][px[u]]);
        add1(a[g][px[u]], a[f][py[u]]);
      }
      for (int u = 1; u <= n; u++)
        add2(s[j * 2], 1ll * a[g][u] * a[g][u]), a[f][u] = 0;
    }
  }
  for (int i = 1; i <= m; i++) {
    memset(a, 0, sizeof(a));
    a[0][i] = 1;
    t[0]++;
    for (int j = 1; j <= k / 2; j++) {
      g = j & 1;
      f = !g;
      for (int u = 1; u < m; u++) {
        add1(a[g][qy[u]], a[f][qx[u]]);
        add1(a[g][qx[u]], a[f][qy[u]]);
      }
      for (int u = 1; u <= m; u++)
        add2(t[j * 2], 1ll * a[g][u] * a[g][u]), a[f][u] = 0;
    }
  }
  for (int o = 0; o <= k; o += 2) s[o] %= 998244353, t[o] %= 998244353;
  for (int o = 0; o <= k; o += 2)
    (ans += c[k][o] * s[o] % 998244353 * t[k - o]) %= 998244353;
  cout << ans << endl;
}
