#include <bits/stdc++.h>
using namespace std;
struct elem {
  int v, ind;
  elem() {}
  elem(int v, int ind) : v(v), ind(ind) {}
};
const long long int modulo = 998244353;
const int limit = 4005;
void add(long long int &a, long long int b) { a = (a + b) % modulo; }
int k;
const int tope = 76;
vector<long long int> waysexcept[limit][tope];
long long int waysone[limit][tope];
vector<long long int> waysoneexcept[limit][tope];
vector<elem> g[limit];
long long int ways[limit][tope];
void compute(int n, long long int WAYS[tope]) {
  for (int u = 1; u <= n; u++) g[u] = vector<elem>();
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    elem eu(v, int(g[v].size()));
    elem ev(u, int(g[u].size()));
    g[u].push_back(eu);
    g[v].push_back(ev);
  }
  for (int u = 1; u <= n; u++) {
    for (int kk = 0; kk <= k; kk += 2) {
      waysexcept[u][kk] = vector<long long int>(int(g[u].size()), 0);
      waysoneexcept[u][kk] = vector<long long int>(int(g[u].size()), 0);
      waysone[u][kk] = 0;
      ways[u][kk] = 0;
    }
    vector<elem> &ar = g[u];
    for (int i = 0; i < int(ar.size()); i++) waysexcept[u][0][i] = 1;
    ways[u][0] = 1;
  }
  WAYS[0] = n;
  for (int kk = 2; kk <= k; kk += 2) {
    for (int u = 1; u <= n; u++) {
      vector<elem> &ar = g[u];
      for (int i = 0; i < int(ar.size()); i++) {
        elem &e = ar[i];
        int v = e.v;
        int ind = e.ind;
        add(waysone[u][kk], waysexcept[v][kk - 2][ind]);
      }
      for (int kkk = 2; kkk <= kk; kkk += 2)
        add(ways[u][kk], waysone[u][kkk] * ways[u][kk - kkk]);
      for (int i = 0; i < int(ar.size()); i++) {
        elem &e = ar[i];
        int v = e.v;
        int ind = e.ind;
        add(waysoneexcept[u][kk][i],
            waysone[u][kk] - waysexcept[v][kk - 2][ind]);
        for (int kkk = 2; kkk <= kk; kkk += 2)
          add(waysexcept[u][kk][i],
              waysoneexcept[u][kkk][i] * waysexcept[u][kk - kkk][i]);
      }
      add(WAYS[kk], ways[u][kk]);
    }
  }
}
int n[2];
long long int sol;
long long int combi[tope][tope];
long long int WAYS[2][tope];
int main() {
  {
    for (int n = 0; n < tope; n++)
      for (int k = 0; k <= n; k++)
        if (k == 0 or k == n)
          combi[n][k] = 1;
        else
          combi[n][k] = (combi[n - 1][k] + combi[n - 1][k - 1]) % modulo;
  }
  cin >> n[0] >> n[1] >> k;
  if (k % 2) {
    cout << 0 << endl;
    exit(0);
  }
  for (int i = 0; i < 2; i++) compute(n[i], WAYS[i]);
  for (int ku = 0; ku <= k; ku += 2) {
    int kv = k - ku;
    add(sol, WAYS[0][ku] * WAYS[1][kv] % modulo * combi[k][ku]);
  }
  sol = (sol % modulo + modulo) % modulo;
  cout << sol << endl;
}
