#include <bits/stdc++.h>
using namespace std;
int n, m, q, u[20], v[20], a[110], b[110], c[110];
long long dp[14][(1 << 13) + 10];
bool check(int rt, int mask, int rt2, int sub) {
  for (int i = 1; i <= m; i++) {
    if ((mask & (1 << u[i])) == 0 || (mask & (1 << v[i])) == 0) continue;
    if (((sub >> u[i]) & 1) == ((sub >> v[i]) & 1)) continue;
    if (v[i] == rt) swap(u[i], v[i]);
    if (u[i] != rt || v[i] != rt2) return 0;
  }
  for (int i = 1; i <= q; i++) {
    if ((mask & (1 << a[i])) == 0 || (mask & (1 << b[i])) == 0) continue;
    if (((sub >> a[i]) & 1) == ((sub >> b[i]) & 1)) continue;
    if (rt != c[i]) return 0;
  }
  return 1;
}
long long go(int root, int mask) {
  if (__builtin_popcount(mask) == 1) return 1;
  if (dp[root][mask] != -1) return dp[root][mask];
  dp[root][mask] = 0;
  int s = mask - (1 << root);
  for (int sub = s; sub > 0; sub = ((sub - 1) & s)) {
    if ((s ^ sub) > sub) continue;
    for (int i = 0; i < n; i++)
      if (sub & (1 << i)) {
        if (check(root, mask, i, sub))
          dp[root][mask] += go(i, sub) * go(root, mask ^ sub);
      }
  }
  return dp[root][mask];
}
int main() {
  scanf("%d %d %d", &n, &m, &q);
  memset(dp, -1, sizeof(dp));
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u[i], &v[i]);
    u[i]--;
    v[i]--;
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    a[i]--;
    b[i]--;
    c[i]--;
    if (a[i] == b[i] && c[i] != a[i]) {
      printf("0\n");
      return 0;
    }
  }
  printf("%lld", go(0, (1 << n) - 1));
  return 0;
}
