#include <bits/stdc++.h>
using namespace std;
long long n, m, Q, x, y, dp[25][1 << 15], mp[105][105], a[105], b[105], c[105];
inline long long lowbit(long long x) { return x & -x; }
inline bool in(long long x, long long S) {
  if (S >> x & 1) return 1;
  return 0;
}
long long dfs(long long u, long long S) {
  long long &ans = dp[u][S];
  if (ans != -1) return ans;
  ans = 0;
  long long S1 = S ^ (1 << (u - 1));
  long long sp;
  for (sp = 0; sp < n; sp++)
    if (in(sp, S1)) break;
  for (long long s = S1; s; s = (s - 1) & S1) {
    if (s >> sp & 1) {
      bool flag = 1;
      for (long long i = 0; i < n; i++) {
        if (i + 1 != u)
          for (long long j = 0; j < n; j++) {
            if (j + 1 != u) {
              if (mp[i + 1][j + 1] && (in(i, s) ^ in(j, s))) {
                flag = false;
                break;
              }
            }
          }
        if (!flag) break;
      }
      if (!flag) continue;
      long long cnt = 0, v = 0;
      for (long long i = 0; i < n; i++) {
        if (mp[u][i + 1] && in(i, s)) {
          cnt++;
          v = i;
        }
      }
      v++;
      if (cnt >= 2) continue;
      for (long long i = 1; i <= Q; i++) {
        if (c[i] == u && in(a[i] - 1, s) && in(b[i] - 1, s)) {
          flag = 0;
          break;
        }
        if (in(c[i] - 1, s) && (!in(a[i] - 1, s) || !in(b[i] - 1, s))) {
          flag = 0;
          break;
        }
      }
      if (!flag) continue;
      if (cnt == 1) {
        ans = ans + dfs(v, s) * dfs(u, S - s);
      } else {
        for (v = 0; v < n; v++)
          if (in(v, s)) ans = ans + dfs(v + 1, s) * dfs(u, S - s);
      }
    }
  }
  return ans;
}
signed main() {
  scanf("%lld%lld%lld", &n, &m, &Q);
  for (long long i = 1; i <= m; i++) {
    scanf("%lld%lld", &x, &y);
    mp[x][y] = mp[y][x] = 1;
  }
  memset(dp, -1, sizeof(dp));
  for (long long i = 0; i < n; i++) dp[i + 1][1 << i] = 1;
  for (long long i = 1; i <= Q; i++) scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
  printf("%lld\n", dfs(1, (1 << n) - 1));
  return 0;
}
