#include <bits/stdc++.h>
using namespace std;
const int N = 15;
struct P {
  int u, v, z;
} lca[N * N];
int edge[N];
long long f[N][1 << N], n, m, q;
void print(int x) {
  int cnt[20], now = 0;
  while (x) {
    cnt[now++] = x % 2;
    x >>= 1;
  }
  for (int i = now - 1; i >= 0; i--) printf("%d", cnt[i]);
}
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--;
    edge[u] |= 1 << v;
    edge[v] |= 1 << u;
  }
  for (int i = 1; i <= q; i++) {
    int u, v, z;
    scanf("%d %d %d", &u, &v, &z);
    if (u == v && v != z) {
      printf("%d\n", 0);
      return 0;
    }
    u--;
    v--;
    z--;
    lca[i].u = u;
    lca[i].v = v;
    lca[i].z = z;
  }
  for (int mask = 0; mask < (1 << n); mask++) {
    for (int i = 0; i < n; i++) {
      f[i][mask] = 0;
      if ((mask & (1 << i)) == 0) continue;
      int msk = mask ^ ((1 << i));
      if (!msk) {
        f[i][mask] = 1;
        continue;
      }
      int nox = msk & -msk;
      for (int cur = msk; cur; cur = msk & (cur - 1)) {
        if ((~cur) & nox) continue;
        int flag = 0;
        int msk2 = mask ^ cur;
        for (int k = 1; k <= q; k++) {
          int u = lca[k].u;
          int v = lca[k].v;
          int z = lca[k].z;
          if (((1 << u) & msk2) && ((1 << v) & cur) && (z != i)) flag = 1;
          if (((1 << v) & msk2) && ((1 << u) & cur) && (z != i)) flag = 1;
        }
        if (flag) continue;
        for (int h = 0; h < n; h++) {
          if (((1 << h) & cur) == 0) continue;
          if ((edge[h] & ((1 << i) | cur)) != edge[h]) continue;
          if (i == 2 && mask == 12) {
          }
          f[i][mask] += f[i][msk2] * f[h][cur];
        }
      }
    }
  }
  printf("%I64d\n", f[0][(1 << n) - 1]);
}
