#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,fma,tune=native")
using namespace std;
namespace {
template <int MOD>
class IntMod {
  static_assert(0 < MOD and MOD <= numeric_limits<int>::max() / 2,
                "MOD out of range");
  int val;

 public:
  IntMod() : val(0) {}
  IntMod(int64_t x) : val(static_cast<int>(x % MOD)) {
    if (val < 0) val += MOD;
  }
  IntMod& operator+=(const IntMod& x) {
    val += x.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  IntMod operator+(const IntMod& x) const {
    IntMod res(*this);
    return res += x;
  }
  IntMod& operator-=(const IntMod& x) {
    val -= x.val;
    if (val < 0) val += MOD;
    return *this;
  }
  IntMod operator-(const IntMod& x) const {
    IntMod res(*this);
    return res -= x;
  }
  IntMod& operator*=(const IntMod& x) {
    val = static_cast<int>(static_cast<long long>(val) * x.val % MOD);
    return *this;
  }
  IntMod operator*(const IntMod& x) const {
    IntMod res(*this);
    return res *= x;
  }
  IntMod& operator/=(const IntMod& x) { return *this *= x.Inv(); }
  IntMod operator/(const IntMod& x) const {
    IntMod res(*this);
    return res /= x;
  }
  IntMod operator-() const {
    IntMod res(*this);
    if (res.val != 0) res.val = MOD - res.val;
    return res;
  }
  IntMod Power(int expon) const {
    IntMod ans(1), temp(*this);
    for (; expon > 0; expon >>= 1) {
      if (expon & 1) ans *= temp;
      temp *= temp;
    }
    return ans;
  }
  IntMod Inv() const {
    int64_t a = MOD, b = val, nx = 1, x = 0;
    while (b != 0) {
      tie(nx, x) = make_pair(x - (a / b) * nx, nx);
      tie(a, b) = make_pair(b, a % b);
    }
    return IntMod(x);
  }
  explicit operator int() const { return val; }
  friend ostream& operator<<(ostream& out, const IntMod& x) {
    return out << x.val;
  }
  bool operator==(const IntMod& x) const { return val == x.val; }
  bool operator!=(const IntMod& x) const { return val != x.val; }
};
const int MOD = 998244353;
const int64_t BIG = int64_t(MOD) * MOD * 8;
int dp[2][4000];
inline void Add(int& a, int b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
struct Tree {
  int n;
  vector<pair<int, int>> edges;
  void Init(int nn) {
    n = nn;
    edges.resize(n - 1);
    for (auto& e : edges) {
      cin >> e.first >> e.second;
      --e.first;
      --e.second;
    }
  }
  void Go(int k, IntMod<MOD>* ways) {
    for (int st = 0, __st = n; st < __st; ++st) {
      memset(dp, 0, sizeof(dp));
      int cur = 0, pred = 1;
      dp[pred][st] = 1;
      ways[0] += 1;
      for (int len = 0, __len = k / 2; len < __len; ++len) {
        memset(dp[cur], 0, sizeof(dp[cur]));
        for (auto& e : edges) {
          Add(dp[cur][e.first], dp[pred][e.second]);
          Add(dp[cur][e.second], dp[pred][e.first]);
        }
        int64_t now = 0;
        for (int v = 0, __v = n; v < __v; ++v) {
          now += int64_t(dp[cur][v]) * dp[cur][v];
          if (now >= BIG) now -= BIG;
        }
        ways[2 * (len + 1)] += now;
        swap(cur, pred);
      }
    }
  }
};
void Solve(int) {
  int n[2], k;
  cin >> n[0] >> n[1] >> k;
  Tree tree[2];
  vector<vector<IntMod<MOD>>> ways(2, vector<IntMod<MOD>>(k + 1));
  for (int t = 0, __t = 2; t < __t; ++t) {
    tree[t].Init(n[t]);
    tree[t].Go(k, ways[t].data());
  }
  vector<vector<IntMod<MOD>>> comb(2 * k + 2, vector<IntMod<MOD>>(2 * k + 2));
  for (int i = 0, __i = ((int)(comb.size())); i < __i; ++i) {
    comb[i][0] = 1;
    for (int j = 1, __j = i + 1; j < __j; ++j)
      comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
  }
  IntMod<MOD> res = 0;
  for (int a = 0, __a = k + 1; a < __a; ++a) {
    res += ways[0][a] * ways[1][k - a] * comb[k][a];
  }
  cout << res << endl;
}
void Gen() {
  ofstream out("big.txt");
  int n = 4000;
  mt19937 rng;
  out << n << " " << n << " 74\n";
  for (int its = 0, __its = 2; its < __its; ++its) {
    for (int v = 2, __v = n + 1; v < __v; ++v) {
      out << v << " " << uniform_int_distribution<>(1, v - 1)(rng) << "\n";
    }
    out << "\n";
  }
}
void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}  // namespace
int32_t main() {
  Init();
  int tests = 1;
  for (int test = 1, __test = tests + 1; test < __test; ++test) Solve(test);
  return 0;
}
