#include <bits/stdc++.h>
using namespace std;
vector<int> nxt[1 << 13], G[15];
vector<pair<int, int> > lca[13];
bool a[14][14], ok[14][1 << 13];
long long int dp[14][1 << 13][2];
int n;
long long int solve(int root, int mask, int check) {
  if (check == 0) {
    int i;
    for (i = 0; i < lca[root].size(); i++) {
      int x = lca[root][i].first, y = lca[root][i].second;
      if ((mask & (1 << x)) == 0 && x != root) return 0;
      if ((mask & (1 << y)) == 0 && y != root) return 0;
    }
  }
  long long int &ret = dp[root][mask][check];
  if (ret != -1) return ret;
  if (mask == 0) return ret = 1;
  ret = 0;
  int i, j, k;
  for (i = 0; i < nxt[mask].size(); i++) {
    int newmask = nxt[mask][i];
    if (!ok[root][newmask]) continue;
    int msb = -1, ch = -1;
    for (k = 0; k < n; k++) {
      if (mask & (1 << k)) msb = k;
      if ((newmask & (1 << k)) && a[root][k]) {
        if (ch == -1)
          ch = k;
        else
          ch = -2;
      }
    }
    if (ch == -2 || (newmask & (1 << msb)) == 0) continue;
    if (ch == -1) {
      for (k = 0; k < n; k++) {
        if (newmask & (1 << k))
          ret +=
              solve(k, newmask ^ (1 << k), 0) * solve(root, mask ^ newmask, 1);
      }
    } else
      ret += solve(ch, newmask ^ (1 << ch), 0) * solve(root, mask ^ newmask, 1);
  }
  return ret;
}
int main() {
  int i, j, m, k, k1, q;
  scanf("%d%d", &n, &m);
  ;
  scanf("%d", &q);
  ;
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    ;
    x--;
    y--;
    G[x].push_back(y);
    G[y].push_back(x);
    a[x][y] = 1;
    a[y][x] = 1;
  }
  while (q--) {
    int x, y, z;
    scanf("%d%d", &x, &y);
    ;
    scanf("%d", &z);
    ;
    x--;
    y--;
    z--;
    lca[z].push_back(make_pair(x, y));
  }
  for (i = 0; i < 1 << n; i++)
    for (j = 0; j < i + 1; j++)
      if ((i & j) == j) nxt[i].push_back(j);
  for (i = 0; i < n; i++) {
    for (j = 0; j < 1 << n; j++) {
      bool f = 1;
      if (j & (1 << i)) continue;
      for (k = 0; k < n; k++) {
        if ((j & (1 << k)) == 0) continue;
        for (k1 = 0; k1 < G[k].size(); k1++)
          if ((j & (1 << G[k][k1])) == 0 && G[k][k1] != i) f = 0;
      }
      for (k = 0; k < lca[i].size(); k++) {
        int x = lca[i][k].first, y = lca[i][k].second;
        if ((j & (1 << x)) && (j & (1 << y))) f = 0;
      }
      ok[i][j] = f;
    }
  }
  memset(dp, -1, sizeof(dp));
  cout << solve(0, ((1 << (n - 1)) - 1) << 1, 0) << endl;
  return 0;
}
