#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int N = 13;
long long n, m, q, u, v, x, y, t, a, b, ans;
long long dp[1 << N][N];
vector<int> G[N];
vector<pair<int, int> > LCA[N];
bool check(int root, int mask1, int mask2) {
  for (int i = 0; i < n; i++)
    if ((1 << i) & mask2)
      for (pair<int, int> p : LCA[i])
        if ((1 << p.first) & mask1 && root != p.second ||
            (1 << p.first) & mask2 && root == p.second)
          return 0;
  mask1 ^= (1 << root);
  for (int i = 0; i < n; i++)
    if ((1 << i) & mask2)
      for (int j : G[i])
        if ((1 << j) & mask1) return 0;
  return 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> q;
  while (m--) {
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  while (q--) {
    cin >> a >> b >> x;
    a--;
    b--;
    x--;
    if (a == b && a != x) return cout << 0 << '\n', 0;
    LCA[a].push_back({b, x});
    LCA[b].push_back({a, x});
  }
  for (int i = 0; i < n; i++) dp[1 << i][i] = 1;
  for (int mask = 1; mask < (1 << n); mask++)
    if (__builtin_popcount(mask) > 1)
      for (int root = 0; root < n; root++)
        if (mask & (1 << root)) {
          int M = mask ^ (1 << root);
          for (int MM = M; MM; MM = (MM - 1) & M)
            if (__builtin_ctz(MM) == __builtin_ctz(M)) {
              int cnt = 0, tmp = 0;
              for (int v : G[root])
                if ((1 << v) & MM) cnt++, tmp = v;
              if (cnt > 1 || !check(root, mask ^ MM, MM)) continue;
              if (cnt == 1) {
                dp[mask][root] += dp[mask ^ MM][root] * dp[MM][tmp];
                continue;
              }
              for (int R = 0; R < n; R++)
                if ((1 << R) & MM)
                  dp[mask][root] += dp[mask ^ MM][root] * dp[MM][R];
            }
        }
  cout << dp[(1 << n) - 1][0] << '\n';
  return 0;
}
