#include <bits/stdc++.h>
using namespace std;
long long n, m, q, dp[14][(1 << 13)], a[105], b[105], c[105], u[14], v[14];
long long dfs(long long now, long long S) {
  if (~dp[now][S]) return dp[now][S];
  long long Fuck = S ^ (1 << (now - 1));
  dp[now][S] = 0;
  long long moved = 1;
  while (!(Fuck & (1 << (moved - 1)))) ++moved;
  for (long long T = Fuck; T; T = (T - 1) & Fuck) {
    long long cnt = 0, to = 0;
    if (!(T & (1 << (moved - 1)))) continue;
    for (long long i = 1; i <= q; ++i)
      if (now == c[i] && (T & (1 << (a[i] - 1))) && (T & (1 << (b[i] - 1))))
        goto fail;
    for (long long i = 1; i <= q; ++i) {
      if ((T & (1 << (c[i] - 1)))) {
        if (!(T & (1 << (a[i] - 1))) || !(T & (1 << (b[i] - 1)))) goto fail;
      }
    }
    for (long long i = 1; i <= m; ++i) {
      if (u[i] == now || v[i] == now) continue;
      if ((T & (1 << (u[i] - 1))) && !(T & (1 << (v[i] - 1)))) goto fail;
      if (!(T & (1 << (u[i] - 1))) && (T & (1 << (v[i] - 1)))) goto fail;
    }
    for (long long i = 1; i <= m; ++i) {
      if (u[i] == now) {
        if ((T & (1 << (v[i] - 1)))) ++cnt, to = v[i];
      } else if (v[i] == now) {
        if ((T & (1 << (u[i] - 1)))) ++cnt, to = u[i];
      }
    }
    if (cnt == 0) {
      for (long long i = 1; i <= n; ++i)
        if ((T & (1 << (i - 1))))
          dp[now][S] += dfs(i, T) * dfs(now, Fuck ^ T ^ (1 << (now - 1)));
    } else if (cnt == 1) {
      dp[now][S] += dfs(to, T) * dfs(now, Fuck ^ T ^ (1 << (now - 1)));
    }
  fail:;
  }
  return dp[now][S];
}
int main() {
  cin >> n >> m >> q;
  memset(dp, -1, sizeof dp);
  for (long long i = 1; i <= n; ++i) dp[i][1 << (i - 1)] = 1;
  for (long long i = 1; i <= m; ++i) cin >> u[i] >> v[i];
  for (long long i = 1; i <= q; ++i) cin >> a[i] >> b[i] >> c[i];
  dfs(1, (1 << n) - 1);
  cout << dp[1][(1 << n) - 1] << endl;
  return 0;
}
