#include <bits/stdc++.h>
using namespace std;
int n, lca[16][16], edge[16][16];
long long dp[16][1 << 16];
bool check(int x, int s1, int s2) {
  if (s1 < s2) return 0;
  bool flag = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if ((1 << i & s1) && (1 << j & s2)) {
        if (edge[i][j]) return 0;
        if (~lca[i][j] && lca[i][j] != x) return 0;
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if ((1 << i & s1) && (1 << j & s1)) {
        if (edge[x][i] && edge[x][j] && i != j) return 0;
        if (~lca[i][j] && lca[i][j] == x) return 0;
      }
  return 1;
}
bool chk(int x, int s, int t) {
  for (int i = 0; i < n; i++)
    if (1 << i & s) {
      if (~lca[x][i] && lca[x][i] != x) return 0;
      if (edge[t][i]) return 0;
    }
  return 1;
}
long long dfs(int x, int s) {
  if (s == 0) return 1;
  long long &t = dp[x][s];
  if (t == -1) {
    t = 0;
    for (int i = 0; i <= s; i++) {
      if ((i & s) != i) continue;
      if (!check(x, i, s ^ i)) continue;
      for (int j = 0; j < n; j++)
        if (((1 << j) & i) && chk(j, i - (1 << j), x))
          t += dfs(j, i - (1 << j)) * dfs(x, s ^ i);
    }
  }
  return t;
}
int main() {
  memset(dp, -1, sizeof(dp));
  memset(lca, -1, sizeof(lca));
  int m, q, i, a, b, c;
  scanf("%d %d %d", &n, &m, &q);
  int k = (1 << n) - 1;
  for (i = 1; i <= m; i++) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    edge[a][b] = edge[b][a] = 1;
  }
  for (i = 1; i <= q; i++) {
    scanf("%d %d %d", &a, &b, &c);
    a--;
    b--;
    c--;
    if (~lca[a][b] && lca[a][b] != c) {
      puts("0");
      return 0;
    }
    if (a == b && c != a) {
      puts("0");
      return 0;
    }
    if ((!a || !b) && c) {
      puts("0");
      return 0;
    }
    lca[a][b] = c;
    lca[b][a] = c;
  }
  cout << dfs(0, k - 1) << endl;
  return 0;
}
