#include <bits/stdc++.h>
using namespace std;
const int N = 15;
int u[N << 3], v[N << 3], lca[N << 3], g[N][N];
int n, m, q;
long long DP[N][1 << N];
bool isOn(int x, int i) { return x & (1 << i); }
long long dfs(int root, int mask) {
  int subnet = mask ^ (1 << root);
  if (subnet == 0) return 1LL;
  long long &ret = DP[root][mask];
  if (~ret) return ret;
  int pos = 0;
  for (int i = n - 1; i >= 0; i -= 1) {
    if (isOn(subnet, i)) {
      pos = i;
      break;
    }
  }
  ret = 0LL;
  for (int submask = subnet; submask; submask = (submask - 1) & subnet) {
    if (!isOn(submask, pos)) continue;
    bool flag = true;
    for (int i = 0; i < n; i += 1) {
      if (i == root) continue;
      for (int j = 0; j < n; j += 1) {
        if (j == root) continue;
        if (g[i][j] && (isOn(submask, i) ^ isOn(submask, j))) {
          flag = false;
          break;
        }
      }
      if (!flag) break;
    }
    if (!flag) continue;
    int newRoot, adjacenttoRootinSubmask = 0;
    for (int i = 0; i < n; i += 1) {
      if (g[root][i] && isOn(submask, i)) {
        adjacenttoRootinSubmask += 1;
        newRoot = i;
      }
    }
    if (adjacenttoRootinSubmask > 1) continue;
    for (int i = 1; i <= q; i += 1) {
      if (root == lca[i] && isOn(submask, u[i]) && isOn(submask, v[i])) {
        flag = false;
        break;
      }
      if (isOn(submask, lca[i]) &&
          !(isOn(submask, u[i]) && isOn(submask, v[i]))) {
        flag = false;
        break;
      }
    }
    if (!flag) continue;
    if (adjacenttoRootinSubmask == 1) {
      ret = (ret + dfs(newRoot, submask) * dfs(root, mask ^ submask));
    } else {
      for (int i = 0; i < n; i += 1) {
        if (isOn(submask, i)) {
          ret = (ret + dfs(i, submask) * dfs(root, mask ^ submask));
        }
      }
    }
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> q;
  for (int i = 1; i <= m; i += 1) {
    int a, b;
    cin >> a >> b;
    a -= 1;
    b -= 1;
    g[a][b] = 1;
    g[b][a] = 1;
  }
  for (int i = 1; i <= q; i += 1) {
    cin >> u[i] >> v[i] >> lca[i];
    u[i] -= 1;
    v[i] -= 1;
    lca[i] -= 1;
  }
  memset(DP, -1, sizeof DP);
  cout << dfs(0, (1 << n) - 1);
  return 0;
}
