#include <bits/stdc++.h>
const int MAXN = 15;
int n, m, q;
long long f[15][(1 << MAXN) + 7];
struct Edge {
  int u, v;
} e[MAXN];
struct LCA {
  int a, b, c;
} a[MAXN * MAXN];
inline bool in(int x, int s) { return ((s >> x) & 1); }
long long dfs(int u, int s) {
  long long &ret = f[u][s];
  if (__builtin_popcount(s) == 1) return ret = in(u, s);
  if (ret != -1) return ret;
  ret = 0;
  int min, ss = s ^ (1 << u);
  for (int i = (0); i <= (n - 1); ++i)
    if (in(i, ss)) {
      min = i;
      break;
    }
  for (int t = ss; t; t = (t - 1) & ss) {
    if (!in(min, t)) continue;
    bool flag = 1;
    for (int i = (1); i <= (q); ++i) {
      if (u == a[i].c && in(a[i].a, t) && in(a[i].b, t)) {
        flag = 0;
        break;
      }
      if (in(a[i].c, t) && (!in(a[i].a, t) || !in(a[i].b, t))) {
        flag = 0;
        break;
      }
    }
    if (!flag) continue;
    int c = 0, v = 0;
    for (int i = (1); i <= (m); ++i) {
      if (u == e[i].u || u == e[i].v) {
        int o = (u == e[i].u ? e[i].v : e[i].u);
        if (in(o, t)) c++, v = o;
        if (c > 1) {
          flag = 0;
          break;
        }
      } else if (in(e[i].u, t) ^ in(e[i].v, t)) {
        flag = 0;
        break;
      }
    }
    if (!flag) continue;
    if (c)
      ret += dfs(v, t) * dfs(u, s ^ t);
    else {
      for (int v = (0); v <= (n - 1); ++v)
        if (in(v, t)) ret += dfs(v, t) * dfs(u, s ^ t);
    }
  }
  return ret;
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  for (int i = (1); i <= (m); ++i)
    scanf("%d %d", &e[i].u, &e[i].v), e[i].u--, e[i].v--;
  for (int i = (1); i <= (q); ++i)
    scanf("%d %d %d", &a[i].a, &a[i].b, &a[i].c), a[i].a--, a[i].b--, a[i].c--;
  memset(f, -1, sizeof f);
  for (int i = (0); i <= (n - 1); ++i) f[i][1 << i] = 1;
  printf("%lld\n", dfs(0, (1 << n) - 1));
  return 0;
}
