#include <bits/stdc++.h>
using namespace std;
namespace FGF {
int n, m, Q;
const int N = 13, M = 110;
long long f[N + 5][(1 << N) + 5];
int g[N][N], lca[M][3], U[N], V[N];
void work() {
  scanf("%d%d%d", &n, &m, &Q);
  for (int i = 1, u, v; i <= m; i++)
    scanf("%d%d", &U[i], &V[i]), U[i]--, V[i]--,
        g[U[i]][V[i]] = g[V[i]][U[i]] = 1;
  for (int i = 1; i <= Q; i++)
    scanf("%d%d%d", &lca[i][0], &lca[i][1], &lca[i][2]), lca[i][0]--,
        lca[i][1]--, lca[i][2]--;
  for (int i = 0; i < n; i++) f[i][1 << i] = 1;
  for (int s = 1; s < (1 << n); s++)
    for (int i = 0, v; i < n; i++)
      if ((s >> i) & 1) {
        for (int j = 0; j < n; j++)
          if (i != j && ((s >> j) & 1)) {
            v = j;
            break;
          }
        for (int vs = s ^ (1 << i), t = vs; t; t = (t - 1) & vs)
          if ((t >> v) & 1) {
            bool fl = 1;
            int x, cnt = 0;
            for (int j = 1; j <= m; j++)
              if (U[j] != i && V[j] != i &&
                  (((t >> U[j]) & 1) ^ ((t >> V[j]) & 1)))
                fl = 0;
            if (!fl) continue;
            for (int j = 1; j <= Q; j++) {
              if (lca[j][2] == i && ((t >> lca[j][0]) & 1) &&
                  ((t >> lca[j][1]) & 1))
                fl = 0;
              if ((t >> lca[j][2] & 1) &&
                  (!(t >> lca[j][0] & 1) || !(t >> lca[j][1] & 1)))
                fl = 0;
            }
            if (!fl) continue;
            for (int j = 0; j < n; j++)
              if (g[i][j] && (t >> j & 1)) x = j, cnt++;
            if (!cnt) {
              for (int j = 0; j < n; j++)
                if (t >> j & 1) f[i][s] += f[j][t] * f[i][s ^ t];
            } else if (cnt == 1)
              f[i][s] += f[x][t] * f[i][s ^ t];
          }
      }
  printf("%lld", f[0][(1 << n) - 1]);
}
}  // namespace FGF
int main() {
  FGF::work();
  return 0;
}
