#include <bits/stdc++.h>
using namespace std;
int n, m, STARE;
long long dp[14][(1 << 13)];
bool bad[14][(1 << 13)], edge[14][14], superior[14][14];
int k1[105], k2[105], k3[105], q, kk1[14], kk2[14];
vector<pair<int, int> > Kkt[14];
vector<int> L[14];
inline bool Ok(int nod, int stare, int x) {
  for (auto it : L[nod])
    if ((stare & (1 << (it - 1))) && x != it) return false;
  return true;
}
inline bool bun(int x, int y) {
  if ((1 << (x - 1)) & y) return true;
  return false;
}
inline bool Good(int x, int nod, int y) {
  int i;
  STARE = (1 << (nod - 1)) + x + y;
  for (i = 1; i <= q; ++i) {
    if (!(STARE & (1 << k1[i] - 1)) || !(STARE & (1 << k2[i] - 1)) ||
        !(STARE & (1 << k3[i] - 1)))
      continue;
    if (k3[i] == nod) {
      if ((bun(k1[i], x) && bun(k2[i], x))) return false;
    } else if (!(bun(k1[i], x) && bun(k2[i], x) && bun(k3[i], x)) &&
               !(bun(k1[i], y) && bun(k2[i], y) && bun(k3[i], y)))
      return false;
  }
  for (i = 1; i <= m; ++i) {
    if (!(STARE & (1 << (kk1[i] - 1))) || !(STARE & (1 << (kk2[i] - 1))))
      continue;
    if ((bun(kk1[i], x) && bun(kk2[i], y)) ||
        (bun(kk1[i], y) && bun(kk2[i], x)))
      return false;
  }
  return true;
}
inline long long memo(int nod, int stare) {
  if (dp[nod][stare] != -1) return dp[nod][stare];
  int i, cnt, t, stare1, cntt, x;
  if (!((1 << (nod - 1)) & stare)) {
    dp[nod][stare] = 0;
    return 0;
  }
  dp[nod][stare] = 0;
  x = (stare ^ (1 << (nod - 1)));
  for (i = 1; i <= n; ++i)
    if (((1 << (i - 1)) & x) && superior[i][nod]) {
      dp[nod][stare] = 0;
      return 0;
    }
  int ales = x - (x & (x - 1));
  for (stare1 = x; stare1 > 0; stare1 = ((stare1 - 1) & x)) {
    if (!(stare1 & ales) || !Good(stare1, nod, x - stare1)) continue;
    for (i = 1; i <= n; ++i)
      if (((1 << (i - 1)) & stare1) && bad[nod][stare1] && Ok(nod, stare1, i)) {
        dp[nod][stare] += 1LL * memo(nod, stare - stare1) * memo(i, stare1);
      }
  }
  return dp[nod][stare];
}
int main() {
  int i, j, x, y, z;
  cin.sync_with_stdio(0);
  cin >> n >> m >> q;
  for (i = 1; i <= m; ++i) {
    cin >> x >> y;
    kk1[i] = x;
    kk2[i] = y;
    L[x].push_back(y);
    L[y].push_back(x);
    edge[x][y] = edge[y][x] = true;
  }
  for (i = 1; i <= q; ++i) {
    cin >> x >> y >> z;
    k1[i] = x;
    k2[i] = y;
    k3[i] = z;
    Kkt[z].push_back(make_pair(x, y));
    superior[z][x] = superior[z][y] = 1;
  }
  for (i = 1; i <= n; ++i)
    for (j = 0; j < (1 << n); ++j) {
      bad[i][j] = 1;
      for (auto it : Kkt[i])
        if (((1 << (it.first - 1)) & j) && ((1 << (it.second - 1)) & j))
          bad[i][j] = 0;
    }
  for (i = 1; i <= n; ++i)
    for (j = 0; j < (1 << n); ++j) dp[i][j] = -1;
  for (i = 1; i <= n; ++i) dp[i][(1 << (i - 1))] = 1;
  cout << memo(1, (1 << n) - 1) << "\n";
  return 0;
}
