#include <bits/stdc++.h>
using namespace std;
const int N = 15;
int n, m, q;
long long dp[N][1 << N];
vector<int> G[N];
vector<pair<int, int> > lim[N];
long long dfs(int u, int S) {
  if (dp[u][S] != -1) return dp[u][S];
  if (__builtin_popcount(S) == 1) return dp[u][S] = (S >> u) & 1;
  int pos = 0;
  for (int i = 0; i < n; i++)
    if (S & (1 << i) && i != u) {
      pos = i;
      break;
    }
  long long res = 0;
  for (int status = S ^ (1 << u); status;
       status = (status - 1) & (S ^ (1 << u))) {
    if (!(status & (1 << pos))) continue;
    bool flag = true;
    for (auto [a, b] : lim[u])
      if ((status & (1 << a)) && (status & (1 << b))) {
        flag = false;
        break;
      }
    if (!flag) continue;
    for (int c = 0; c < n; c++)
      if (status & (1 << c)) {
        for (auto [a, b] : lim[c])
          if ((!(status & (1 << a))) || (!(status & (1 << b)))) {
            flag = false;
            break;
          }
        if (!flag) break;
      }
    if (!flag) continue;
    for (int x = 0; x < n; x++)
      if (status & (1 << x)) {
        for (int y : G[x])
          if ((!(status & (1 << y))) && y != u) {
            flag = false;
            break;
          }
        if (!flag) break;
      }
    if (!flag) continue;
    vector<int> to;
    for (int v : G[u])
      if (status & (1 << v)) to.push_back(v);
    if (to.size() >= 2) continue;
    if (to.size() == 1) {
      int v = to.front();
      res = (res + dfs(v, status) * dfs(u, S ^ status));
    }
    if (to.size() == 0) {
      for (int v = 0; v < n; v++)
        if (status & (1 << v))
          res = (res + dfs(v, status) * dfs(u, S ^ status));
    }
  }
  return dp[u][S] = res;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--, v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= q; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    a--, b--, c--;
    lim[c].emplace_back(a, b);
  }
  memset(dp, -1, sizeof(dp));
  printf("%lld", dfs(0, (1 << n) - 1));
  return 0;
}
