#include <bits/stdc++.h>
using namespace std;
long long f[13][1 << 13];
long long u[14], v[14];
long long a[101], b[101], c[101], m, q;
bool vis[14][1 << 13];
long long n;
inline bool check(long long rt, long long x, long long ch, long long y) {
  for (long long i = 1; i <= m; i++) {
    if ((x & (1 << u[i])) == 0 || (x & (1 << v[i])) == 0) continue;
    if (((y >> u[i]) & 1) == ((y >> v[i]) & 1)) continue;
    if (v[i] == rt) swap(u[i], v[i]);
    if (u[i] != rt || v[i] != ch) return 0;
  }
  for (long long i = 1; i <= q; i++) {
    if ((x & (1 << a[i])) == 0 || (x & (1 << b[i])) == 0) continue;
    if (((y >> a[i]) & 1) == ((y >> b[i]) & 1)) continue;
    if (rt != c[i]) return 0;
  }
  return 1;
}
inline long long dp(long long root, long long x) {
  if ((x & -x) == x) return 1;
  if (vis[root][x]) return f[root][x];
  vis[root][x] = 1;
  f[root][x] = 0;
  long long s = x - (1 << root);
  for (long long i = (s & -s); i <= s; i += ((s & -s) << 1))
    if ((s & i) == i) {
      for (long long j = 0; j < n; j++)
        if (i & (1 << j)) {
          if (!check(root, x, j, i)) continue;
          f[root][x] += dp(j, i) * dp(root, x ^ i);
        }
    }
  return f[root][x];
}
signed main() {
  scanf("%lld%lld%lld", &n, &m, &q);
  for (long long i = 1, a, b; i <= m; i++) {
    scanf("%lld%lld", &a, &b);
    a--;
    b--;
    u[i] = a;
    v[i] = b;
  }
  for (long long i = 1; i <= q; i++) {
    scanf("%lld%lld%lld", a + i, b + i, c + i);
    if (a[i] == b[i] && a[i] != c[i]) return puts("0"), 0;
    a[i]--;
    b[i]--;
    c[i]--;
  }
  printf("%lld", dp(0, (1 << n) - 1));
}
