#include <bits/stdc++.h>
using namespace std;
const int N = 13, M = 105;
inline int read() {
  int s = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9')
    s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  return s;
}
int n, m, q, u[M], v[M], a[M], b[M], c[M];
long long dp[N][1 << N];
bool vs[N][1 << N];
bool in(int x, int S) { return S & (1 << x); }
long long dfs(int x, int S) {
  int Sd = S, pos = -1;
  if (!vs[x][S]) {
    S &= ~(1 << x);
    vs[x][Sd] = 1;
    while (1)
      if (in(++pos, S)) break;
    for (register int T = S; T; T = (T - 1) & S)
      if (in(pos, T)) {
        int can = 1, edge = 0, y = -1;
        for (register int i = 1; i <= q && can; i++) {
          if (x == c[i] && in(a[i], T) && in(b[i], T)) can = 0;
          if (in(c[i], T) && in(a[i], T) + in(b[i], T) < 2) can = 0;
        }
        if (!can) continue;
        for (register int i = 1; i <= m; i++)
          if (v[i] == x) swap(u[i], v[i]);
        for (register int i = 1; i <= m && can; i++)
          if (u[i] != x && in(u[i], T) + in(v[i], T) == 1) can = 0;
        if (!can) continue;
        for (register int i = 1; i <= m; i++)
          if (u[i] == x && in(v[i], T)) edge++, y = v[i];
        if (edge == 1) dp[x][Sd] += dfs(y, T) * dfs(x, S ^ T | 1 << x);
        if (edge == 0)
          for (register int i = 0; i < n; i++)
            if (in(i, T)) dp[x][Sd] += dfs(i, T) * dfs(x, S ^ T | 1 << x);
      }
  }
  return dp[x][Sd];
}
int main() {
  n = read();
  m = read();
  q = read();
  for (register int i = 1; i <= m; i++) u[i] = read() - 1, v[i] = read() - 1;
  for (register int i = 1; i <= q; i++)
    a[i] = read() - 1, b[i] = read() - 1, c[i] = read() - 1;
  for (register int i = 0; i < n; i++) dp[i][1 << i] = vs[i][1 << i] = 1;
  printf("%lld", dfs(0, (1 << n) - 1));
  return 0;
}
