#include <bits/stdc++.h>
using namespace std;
int N, M, Q;
long long F[20][9000] = {{0}};
int Out[20] = {0};
int LCA[20][110][2] = {{{0}}};
int LCAp[20] = {0};
int Must[20] = {0};
int Cant[20] = {0};
int Link[20][20] = {{0}};
int MustLink[20] = {0};
int main() {
  cin >> N >> M >> Q;
  for (int i = 1; i <= M; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    Out[b] |= (1 << ((a)-1));
    Out[a] |= (1 << ((b)-1));
    Link[a][b] = Link[b][a] = 1;
  }
  for (int i = 1; i <= Q; i++) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == b && b == c) continue;
    LCAp[c]++;
    LCA[c][LCAp[c]][0] = a;
    LCA[c][LCAp[c]][1] = b;
    Must[c] |= (1 << ((a)-1));
    Must[c] |= (1 << ((b)-1));
    if (a != c) Cant[a] |= (1 << ((c)-1));
    if (b != c) Cant[b] |= (1 << ((c)-1));
  }
  for (int i = 1; i <= N; i++) F[i][1 << (i - 1)] = 1;
  for (int SS = 0; SS < (1 << N); SS++) {
    for (int pp = (SS - 1) & SS; pp != 0; pp = (pp - 1) & SS) {
      int qq = SS ^ pp;
      for (int p = 1; p <= N; p++) {
        if ((pp & (1 << ((p)-1))) == 0) continue;
        int flag = 0;
        for (int gg = 1; gg <= LCAp[p]; gg++) {
          int a = LCA[p][gg][0], b = LCA[p][gg][1];
          if ((qq & (1 << ((a)-1))) != 0 && (qq & (1 << ((b)-1))) != 0) {
            flag = 1;
            break;
          }
        }
        if (flag == 1) continue;
        int p_ = pp ^ (1 << ((p)-1));
        if (p_ > qq) continue;
        for (int q = 1; q <= N; q++) {
          if ((qq & (1 << ((q)-1))) == 0) continue;
          if ((Must[q] & qq) != Must[q]) continue;
          if ((Cant[q] & qq) != 0) continue;
          int q_ = qq ^ (1 << ((q)-1));
          if ((q_ & Out[p]) != 0) continue;
          if (Link[p][q] == 1) {
            if ((Out[q] & (qq | (1 << ((p)-1)))) != Out[q]) continue;
          } else if ((Out[q] & qq) != Out[q])
            continue;
          F[p][SS] += F[p][pp] * F[q][qq];
        }
      }
    }
  }
  cout << F[1][(1 << N) - 1] << endl;
  return 0;
}
