#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ '0'), c = getchar();
  return x * f;
}
const int N = 105, M = 13;
int n, m, q;
int e[M][M], u[M], v[M], a[N], b[N], c[N];
long long f[M][1 << M];
inline int in(int x, int s) { return s >> x & 1; }
inline long long dfs(int x, int s) {
  if (~f[x][s]) return f[x][s];
  long long &res = f[x][s];
  res = 0;
  s ^= (1 << x);
  int i;
  for (i = 0; i < n; i++)
    if (in(i, s)) break;
  for (int t = s; t; t = (t - 1) & s)
    if (in(i, t)) {
      int flag = 1;
      for (int k = 1; k <= q; k++)
        if (c[k] == x && in(a[k], t) && in(b[k], t)) {
          flag = 0;
          break;
        }
      if (!flag) continue;
      for (int k = 1; k <= q; k++)
        if (in(c[k], t) && (!in(a[k], t) || !in(b[k], t))) {
          flag = 0;
          break;
        }
      if (!flag) continue;
      for (int k = 1; k <= m; k++)
        if ((u[k] != x && v[k] != x) && (in(u[k], t) ^ in(v[k], t))) {
          flag = 0;
          break;
        }
      if (!flag) continue;
      int cnt = 0, p = 0;
      for (int k = 0; k < n; k++)
        if (e[x][k] && in(k, t)) {
          cnt++;
          p = k;
        }
      if (cnt > 1) continue;
      if (cnt == 1)
        res += dfs(p, t) * dfs(x, s ^ t ^ (1 << x));
      else {
        for (p = 0; p < n; p++)
          if (in(p, t)) res += dfs(p, t) * dfs(x, s ^ t ^ (1 << x));
      }
    }
  return res;
}
int main() {
  n = read(), m = read(), q = read();
  for (int i = 1; i <= m; i++) {
    int x = read() - 1, y = read() - 1;
    u[i] = x, v[i] = y;
    e[x][y] = e[y][x] = 1;
  }
  for (int i = 1; i <= q; i++)
    a[i] = read() - 1, b[i] = read() - 1, c[i] = read() - 1;
  memset(f, -1, sizeof(f));
  for (int i = 0; i < n; i++) f[i][1 << i] = 1;
  printf("%lld\n", dfs(0, (1 << n) - 1));
  return 0;
}
