#include <bits/stdc++.h>
using namespace std;
const int N = 14;
int n, m, q, lca[N][N], lowbit[(1 << N)];
long long dp[N][(1 << N)];
vector<int> need_connect[N];
long long calc(int root, int mask) {
  long long &res = dp[root][mask];
  if (res != -1) return res;
  res = 0;
  for (int newMask = 0; newMask < (1 << n); newMask++) {
    if (lowbit[mask ^ (1 << root)] != lowbit[newMask]) continue;
    if ((mask & newMask) != newMask) continue;
    int otherMask = (mask ^ newMask);
    bool kt = true;
    int NonRoot = otherMask - (1 << root);
    for (int i = 0; i < n; i++) {
      if (i == root) continue;
      if (NonRoot >> i & 1) {
        for (auto &x : need_connect[i])
          if (newMask >> x & 1) kt = false;
      }
    }
    for (int i = 0; i < n; i++) {
      if (newMask >> i & 1) {
        for (int j = 0; j < n; j++) {
          if (otherMask >> j & 1)
            if (lca[i][j] != -1 && lca[i][j] != root) kt = false;
        }
      }
    }
    if (!kt) continue;
    for (int newRoot = 0; newRoot < n; newRoot++) {
      if (newMask >> newRoot & 1) {
        bool ok = true;
        for (int other = 0; other < n; other++) {
          if ((newMask ^ (1 << newRoot)) >> other & 1)
            for (auto &x : need_connect[other])
              if (otherMask >> x & 1) ok = false;
        }
        if (ok) res = res + calc(root, otherMask) * calc(newRoot, newMask);
      }
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  memset(lca, -1, sizeof lca);
  cin >> n >> m >> q;
  while (m--) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    need_connect[u].push_back(v);
    need_connect[v].push_back(u);
  }
  while (q--) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--, c--;
    if (a == b) {
      if (c != a) return cout << 0, 0;
      continue;
    }
    if (lca[a][b] != -1 && lca[a][b] != c) return cout << 0, 0;
    lca[a][b] = c;
    lca[b][a] = c;
  }
  memset(dp, -1, sizeof dp);
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      if (i >> j & 1) {
        lowbit[i] = j;
        break;
      }
    }
  }
  for (int i = 0; i < n; i++) dp[i][(1 << i)] = 1;
  cout << calc(0, (1 << n) - 1);
}
