#include <bits/stdc++.h>
using namespace std;
const int N = 4005;
const int M = 76;
const int mod = 998244353;
int n, m, k, sum[N][M], answer[M], g[N], h[N], binom[M][M], f_a[N][M],
    f_b[N][M], pd[N][M], dd[N][M];
vector<int> adj_a[N], adj_b[N];
int add(int x, int y) {
  x += y;
  if (x >= mod) {
    x -= mod;
  }
  return x;
}
int sub(int x, int y) {
  x -= y;
  if (x < 0) {
    x += mod;
  }
  return x;
}
int mul(int x, int y) { return (long long)x * y % mod; }
void up(int x, int p, vector<int> *adj) {
  for (auto y : adj[x]) {
    if (y != p) {
      up(y, x, adj);
    }
  }
  pd[x][0] = 1;
  for (int i = 0; i <= k; i += 2) {
    sum[x][i] = 0;
    for (auto y : adj[x]) {
      sum[x][i] = add(sum[x][i], pd[y][i]);
    }
  }
  for (int i = 2; i <= k; i += 2) {
    pd[x][i] = 0;
    for (int j = 0; j <= i - 2; j += 2) {
      pd[x][i] = add(pd[x][i], mul(sum[x][j], pd[x][i - j - 2]));
    }
  }
}
void down(int x, int p, vector<int> *adj, int f[N][M]) {
  for (int i = 0; i <= k; i += 2) {
    sum[x][i] = add(sum[x][i], dd[x][i]);
  }
  f[x][0] = 1;
  for (int i = 2; i <= k; i += 2) {
    f[x][i] = 0;
    for (int j = 0; j <= i - 2; j += 2) {
      f[x][i] = add(f[x][i], mul(sum[x][j], f[x][i - j - 2]));
    }
  }
  for (auto y : adj[x]) {
    if (y != p) {
      for (int i = 0; i <= k; i += 2) {
        sum[x][i] = sub(sum[x][i], pd[y][i]);
      }
      dd[y][0] = 1;
      for (int i = 2; i <= k; i += 2) {
        dd[y][i] = 0;
        for (int j = 0; j <= i - 2; j += 2) {
          dd[y][i] = add(dd[y][i], mul(sum[x][j], dd[y][i - j - 2]));
        }
      }
      for (int i = 0; i <= k; i += 2) {
        sum[x][i] = add(sum[x][i], pd[y][i]);
      }
      down(y, x, adj, f);
    }
  }
}
void dp(int f[N][M], vector<int> *adj, int n) {
  memset(sum, 0, sizeof sum);
  memset(dd, 0, sizeof dd);
  memset(pd, 0, sizeof pd);
  up(1, 0, adj);
  down(1, 0, adj, f);
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  if (k & 1) {
    puts("0");
    return 0;
  }
  for (int i = 0; i <= k; ++i) {
    binom[i][0] = 1;
    for (int j = 1; j <= i; ++j) {
      binom[i][j] = add(binom[i - 1][j], binom[i - 1][j - 1]);
    }
  }
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    adj_a[x].push_back(y);
    adj_a[y].push_back(x);
  }
  for (int i = 1; i < m; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    adj_b[x].push_back(y);
    adj_b[y].push_back(x);
  }
  dp(f_a, adj_a, n);
  dp(f_b, adj_b, m);
  int result = 0;
  for (int i = 2; i <= k; i += 2) {
    if (k % i == 0) {
      for (int j = 0; j <= i; j += 2) {
        int u = 0, v = 0;
        for (int x = 1; x <= n; ++x) {
          u = add(u, f_a[x][j]);
        }
        for (int x = 1; x <= m; ++x) {
          v = add(v, f_b[x][i - j]);
        }
        answer[i] = add(answer[i], mul(binom[i][j], mul(u, v)));
      }
      for (int j = 2; j < i; j += 2) {
        if (i % j == 0) {
          answer[i] = sub(answer[i], answer[j]);
        }
      }
      result = add(result, answer[i]);
    }
  }
  printf("%d\n", result);
  return 0;
}
