#include <bits/stdc++.h>
using namespace std;
long long f[15][50000], g[15][50000];
int a[105], b[105], c[105], x[105], y[105];
int n, m, q;
long long work(int v, int st);
bool in(int v, int st) {
  if ((1 << v) & st)
    return true;
  else
    return false;
}
long long workg(int v, int st) {
  for (int i = 1; i <= m; ++i)
    if (in(x[i], st) != in(y[i], st))
      if ((x[i] != v) && (y[i] != v)) return 0;
  for (int i = 1; i <= q; ++i)
    if (!in(c[i], st)) {
      if (in(a[i], st) && in(b[i], st)) return 0;
    } else if (((!in(a[i], st)) || (!in(b[i], st))) && (c[i] != v))
      return 0;
  if (g[v][st] >= 0) return g[v][st];
  g[v][st] = work(v, st);
  return g[v][st];
}
long long workf(int v, int st, int fa) {
  for (int i = 1; i <= m; ++i)
    if (in(x[i], st) != in(y[i], st))
      if (((x[i] != v) && (x[i] != fa)) || ((y[i] != v) && (y[i] != fa)))
        return 0;
  for (int i = 1; i <= q; ++i)
    if (!in(c[i], st)) {
      if (in(a[i], st) && in(b[i], st)) return 0;
    } else if ((!in(a[i], st)) || (!in(b[i], st)))
      return 0;
  if (f[v][st] >= 0) return f[v][st];
  f[v][st] = work(v, st);
  return f[v][st];
}
long long work(int v, int st) {
  int nxt = st ^ (1 << v);
  if (nxt == 0) return 1;
  long long dq = 0;
  for (int i = nxt; i > 0; i = (i - 1) & nxt) {
    if ((i & nxt & (-nxt)) == 0) continue;
    for (int u = 0; u < n; ++u)
      if (in(u, i)) dq += workf(u, i, v) * workg(v, st ^ i);
  }
  return dq;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= m; ++i) scanf("%d%d", &x[i], &y[i]);
  for (int i = 1; i <= q; ++i) scanf("%d%d%d", &a[i], &b[i], &c[i]);
  memset(f, -1, sizeof(f));
  memset(g, -1, sizeof(g));
  for (int i = 1; i <= m; ++i) {
    x[i]--;
    y[i]--;
  }
  for (int i = 1; i <= q; ++i) {
    a[i]--;
    b[i]--;
    c[i]--;
  }
  printf("%I64d\n", workf(0, (1 << n) - 1, -1));
  return 0;
}
