#include <bits/stdc++.h>
using namespace std;
int n, m, q, g[13][13], lca[13][13];
long long dp[1 << 13][13];
long long f(int s, int root) {
  s &= ~(1 << root);
  if (s == 0) return 1;
  if (dp[s][root] != -1) return dp[s][root];
  long long res = 0;
  int must = 0;
  for (int i = (0); i < (n); i++)
    if (s & 1 << i) {
      must = i;
      break;
    }
  for (int x = (0); x < (1 << n); x++)
    if (((x | s) == s) && (x & 1 << must)) {
      int ny = s ^ x;
      int y = ny | 1 << root;
      bool bad = false;
      for (int i = (0); i < (n); i++)
        for (int j = (0); j < (n); j++)
          if ((x & 1 << i) && (x & 1 << j)) {
            if (lca[i][j] != -1 && (y & 1 << lca[i][j])) {
              bad = true;
            }
          }
      for (int i = (0); i < (n); i++)
        for (int j = (0); j < (n); j++)
          if ((x & 1 << i) && (y & 1 << j)) {
            if (lca[i][j] != -1 && lca[i][j] != root) {
              bad = true;
            }
          }
      for (int i = (0); i < (n); i++)
        for (int j = (0); j < (n); j++)
          if ((x & 1 << i) && (ny & 1 << j)) {
            if (g[i][j]) bad = true;
          }
      int c = 0, x_root = -1;
      for (int i = (0); i < (n); i++)
        if (x & 1 << i) {
          if (g[root][i]) {
            c++;
            x_root = i;
          }
        }
      if (c >= 2) bad = true;
      if (bad) continue;
      for (int i = (0); i < (n); i++)
        if (x & 1 << i) {
          if (x_root != -1 && i != x_root) continue;
          res += f(x, i) * f(y, root);
        }
    }
  return dp[s][root] = res;
}
int main() {
  cin >> n >> m >> q;
  for (int i = (0); i < (m); i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u][v] = g[v][u] = 1;
  }
  memset(lca, -1, sizeof(lca));
  for (int i = (0); i < (n); i++) lca[i][i] = i;
  for (int i = (0); i < (q); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c--;
    if (lca[a][b] != -1 && lca[a][b] != c) {
      cout << 0 << endl;
      return 0;
    }
    lca[a][b] = lca[b][a] = c;
  }
  memset(dp, -1, sizeof(dp));
  cout << f((1 << n) - 1, 0) << endl;
  return 0;
}
