#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &x) {
  x = 0;
  long long f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f = ch == '-', ch = getchar();
  while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
  x = f ? -x : x;
}
const long long N = 15, M = 105;
long long mp[N][N], f[N][1 << N], n, m, q;
struct lca {
  long long x, y, z;
} L[M];
struct xy {
  long long x, y;
} B[M];
bool in(long long x, long long y) { return x & (1 << y); }
long long dfs(long long u, long long mask) {
  if (~f[u][mask]) return f[u][mask];
  long long &now = f[u][mask];
  mask ^= (1 << u), now = 0;
  long long pos;
  for (long long i = 0; i < n; i++)
    if (mask & (1 << i)) {
      pos = i;
      break;
    }
  for (long long sub = mask; sub; sub = (sub - 1) & mask) {
    if (!(sub & (1 << pos))) continue;
    long long flag = 0, v = -1;
    for (long long i = 1; i <= q; i++)
      if (in(sub, L[i].z)) {
        if (!in(sub, L[i].x) || !in(sub, L[i].y)) {
          flag = 1;
          break;
        }
      } else if (u == L[i].z) {
        if (in(sub, L[i].x) && in(sub, L[i].y)) {
          flag = 1;
          break;
        }
      }
    if (flag) continue;
    for (long long i = 1; i <= m; i++)
      if (B[i].x != u && B[i].y != u && (in(sub, B[i].x) ^ in(sub, B[i].y))) {
        flag = 1;
        break;
      }
    if (flag) continue;
    for (long long i = 0; i < n; i++)
      if (mp[u][i] && in(sub, i))
        if (!~v)
          v = i;
        else {
          flag = 1;
          break;
        }
    if (flag) continue;
    if (~v)
      now = (now + dfs(u, mask ^ (1 << u) ^ sub) * dfs(v, sub));
    else
      for (long long i = 0; i < n; i++)
        if (in(sub, i))
          now = (now + dfs(u, mask ^ (1 << u) ^ sub) * dfs(i, sub));
  }
  return now;
}
signed main() {
  read(n), read(m), read(q);
  for (long long i = 1, x, y; i <= m; i++)
    read(B[i].x), read(B[i].y), --B[i].x, --B[i].y,
        mp[B[i].x][B[i].y] = mp[B[i].y][B[i].x] = 1;
  for (long long x, y, z, i = 1; i <= q; i++)
    read(L[i].x), read(L[i].y), read(L[i].z), L[i].x--, L[i].y--, L[i].z--;
  memset(f, -1, sizeof(f));
  for (long long i = 0; i < n; i++) f[i][1 << i] = 1;
  printf("%lld", dfs(0, (1 << n) - 1));
}
