#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
int n, m, k;
long long dp[1 << 13][14];
bool g[15][15];
int bc[1 << 13];
int lca[15][15];
long long calc_dp(int mask, int root) {
  if (dp[mask][root] > -1) {
    return dp[mask][root];
  }
  if (bc[mask] == 1) {
    return dp[mask][root] = 1LL;
  }
  dp[mask][root] = 0LL;
  int bmask = mask ^ (1 << (root - 1));
  int last_bit = bmask ^ (bmask & (bmask - 1));
  bmask = bmask ^ last_bit;
  for (int maskit = bmask;; maskit = (maskit - 1) & bmask) {
    int smask = maskit ^ last_bit;
    bool fail = false;
    for (int i = 1; i <= n; i++) {
      if (smask & (1 << (i - 1))) {
        for (int j = 1; j <= n; j++) {
          if (g[i][j] && j != root && !(smask & (1 << (j - 1)))) {
            fail = true;
          }
        }
        for (int j = 1; j <= n; j++) {
          if (lca[i][j] && (mask & (1 << (j - 1))) &&
              !(smask & (1 << (j - 1))) && lca[i][j] != root) {
            fail = true;
          }
        }
      }
    }
    if (!fail) {
      for (int i = 1; i <= n; i++) {
        if (smask & (1 << (i - 1))) {
          dp[mask][root] += calc_dp(smask, i) * calc_dp(mask ^ smask, root);
        }
      }
    }
    if (!maskit) {
      break;
    }
  }
  return dp[mask][root];
}
void precalc() {
  for (int mask = 1; mask < (1 << 13); mask++) {
    bc[mask] = bc[mask & (mask - 1)] + 1;
  }
}
void solve() {
  memset(dp, 255, sizeof(dp));
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= m; i++) {
    int v1, v2;
    scanf("%d%d", &v1, &v2);
    g[v1][v2] = g[v2][v1] = true;
  }
  for (int i = 1; i <= k; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == b && c != a) {
      printf("0\n");
      return;
    }
    if (lca[a][b] && lca[a][b] != c) {
      printf("0\n");
      return;
    }
    lca[a][b] = lca[b][a] = c;
  }
  printf("%I64d\n", calc_dp((1 << n) - 1, 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  srand(1363);
  precalc();
  solve();
  return 0;
}
