#include <bits/stdc++.h>
int f[20][20], n, m, q, x, y, a, b, c;
long long dp[14][1 << 13];
std::vector<int> e[20];
long long dfs(int rt, int s) {
  if (dp[rt][s] != -1) return dp[rt][s];
  int p = -1;
  long long ans = 0;
  for (int i = 0; i < n; i++)
    if ((s & (1 << i)) && i != rt) {
      p = i;
      break;
    }
  if (p == -1) return 1;
  std::vector<int> t1, t2;
  t1.clear(), t2.clear();
  for (int j = (s - 1) & s; j; j = (j - 1) & s) {
    if ((j & (1 << rt)) == 0) continue;
    int res = s ^ j, cnt1 = 0, cnt2 = 0;
    if ((res & (1 << p)) == 0) continue;
    t1.clear(), t2.clear();
    for (int k = 0; k < n; k++)
      if (j & (1 << k))
        t1.push_back(k);
      else if (res & (1 << k))
        t2.push_back(k);
    int ff = 1;
    for (int k : t1)
      for (int k2 : t2)
        if (f[k][k2] != -1 && f[k][k2] != rt) {
          ff = 0;
          break;
        }
    if (!ff) continue;
    for (int u : t2) {
      int ft = 1;
      for (auto to : e[u])
        if (to != rt && (res & (1 << to)) == 0) {
          ft = 0;
          break;
        }
      if (!ft) continue;
      ans = ans + 1ll * dfs(rt, j) * dfs(u, res);
    }
  }
  dp[rt][s] = ans;
  return ans;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    x--, y--;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  memset(dp, -1, sizeof(dp));
  memset(f, -1, sizeof(f));
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &a, &b, &c);
    a--, b--, c--;
    if (a == b && a != c) {
      puts("0");
      return 0;
    }
    if (f[a][b] != -1 && f[a][b] != c) {
      puts("0");
      return 0;
    }
    f[a][b] = c, f[b][a] = c;
  }
  printf("%lld\n", dfs(0, (1 << n) - 1));
}
