#include <bits/stdc++.h>
using namespace std;
namespace zyt {
template <typename T>
inline void read(T &x) {
  char c;
  bool f = false;
  x = 0;
  do c = getchar();
  while (c != '-' && !isdigit(c));
  if (c == '-') f = true, c = getchar();
  do x = x * 10 + c - '0', c = getchar();
  while (isdigit(c));
  if (f) x = -x;
}
template <typename T>
inline void write(T x) {
  static char buf[20];
  char *pos = buf;
  if (x < 0) putchar('-'), x = -x;
  do *pos++ = x % 10 + '0';
  while (x /= 10);
  while (pos > buf) putchar(*--pos);
}
const int N = 13, Q = 110;
int n, m, q, lg2[1 << N];
long long f[N][1 << N];
struct edge {
  int u, v;
} e[N];
struct lca {
  int a, b, c;
} lim[Q];
inline bool check(const int a, const int p) { return a & (1 << p); }
inline int lowbit(const int x) { return x & (-x); }
long long dfs(const int u, const int tree) {
  if (~f[u][tree]) return f[u][tree];
  int tmp = (tree ^ (1 << u));
  if (!lowbit(tmp)) return f[u][tree] = 1;
  f[u][tree] = 0;
  int x = lg2[lowbit(tmp)];
  for (int ntree = tmp; ntree; ntree = (ntree - 1) & tmp) {
    if (!check(ntree, x)) continue;
    bool flag = false;
    for (int i = 0; i < m; i++)
      if (e[i].u != u && e[i].v != u &&
          check(ntree, e[i].u) ^ check(ntree, e[i].v)) {
        flag = true;
        break;
      }
    if (flag) continue;
    int v, cnt = 0;
    for (int i = 0; i < m; i++)
      if (e[i].u == u && check(ntree, e[i].v))
        v = e[i].v, ++cnt;
      else if (e[i].v == u && check(ntree, e[i].u))
        v = e[i].u, ++cnt;
    if (cnt > 1) continue;
    flag = false;
    for (int i = 0; i < q; i++) {
      int a = lim[i].a, b = lim[i].b, c = lim[i].c;
      if (c == u && check(ntree, a) && check(ntree, b)) {
        flag = true;
        break;
      }
      if (check(ntree, c) && !(check(ntree, a) && check(ntree, b))) {
        flag = true;
        break;
      }
    }
    if (flag) continue;
    if (cnt == 1)
      f[u][tree] += dfs(v, ntree) * dfs(u, tree ^ ntree);
    else
      for (int tmp = ntree; tmp; tmp -= lowbit(tmp))
        f[u][tree] += dfs(lg2[lowbit(tmp)], ntree) * dfs(u, tree ^ ntree);
  }
  return f[u][tree];
}
int work() {
  read(n), read(m), read(q);
  memset(f, -1, sizeof(f));
  for (int i = 0; i < n; i++) lg2[1 << i] = i;
  for (int i = 0; i < m; i++) {
    read(e[i].u), read(e[i].v);
    --e[i].u, --e[i].v;
  }
  for (int i = 0; i < q; i++) {
    read(lim[i].a), read(lim[i].b), read(lim[i].c);
    --lim[i].a, --lim[i].b, --lim[i].c;
  }
  write(dfs(0, (1 << n) - 1));
  return 0;
}
}  // namespace zyt
int main() { return zyt::work(); }
