#include <bits/stdc++.h>
int n, m, q;
long long dp[20][1 << 15];
struct Lca_ {
  int a[300], b[300];
  int cnt;
} lca[300];
struct Edge_ {
  int a, b;
} e[20];
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1; i <= n; ++i) {
    dp[i][1 << (i - 1)] = 1;
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &e[i].a, &e[i].b);
  }
  for (int i = 1; i <= q; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    ++lca[c].cnt;
    lca[c].a[lca[c].cnt] = a, lca[c].b[lca[c].cnt] = b;
  }
  for (int S = 0; S < (1 << n); ++S) {
    for (int i = 1; i <= n; ++i) {
      if ((S & (1 << (i - 1))) == 0) continue;
      int s = S ^ (1 << (i - 1));
      int t = (s & (-s));
      for (int ins = s; ins; ins = (ins - 1) & s) {
        if ((ins & t) == 0) continue;
        int count = 0, V = 0;
        bool flag = 0;
        for (int j = 1; j <= m; ++j) {
          if (e[j].a == i || e[j].b == i) {
            if (e[j].b == i) std::swap(e[j].a, e[j].b);
            if (ins & (1 << (e[j].b - 1))) {
              ++count;
              V = e[j].b;
              if (count > 1) break;
            }
            continue;
          }
          flag |= ((!!(ins & (1 << (e[j].a - 1)))) ^
                   (!!(ins & (1 << (e[j].b - 1)))));
          if (flag) break;
        }
        if (count > 1) continue;
        if (flag) continue;
        for (int l = 1; l <= n; ++l) {
          for (int j = 1; j <= lca[l].cnt; ++j) {
            if (l == i)
              flag |= ((!!(ins & (1 << (lca[i].a[j] - 1)))) &
                       (!!(ins & (1 << (lca[i].b[j] - 1)))));
            else
              flag |= ((!!(ins & (1 << (l - 1)))) &
                       ((!(ins & (1 << (lca[l].a[j] - 1)))) |
                        (!(ins & (1 << (lca[l].b[j] - 1)))))) |
                      (((!!(ins & (1 << (lca[l].a[j] - 1)))) &
                        (!!(ins & (1 << (lca[l].b[j] - 1))))) &
                       (!(ins & (1 << (l - 1)))));
            if (flag) break;
          }
        }
        if (flag) continue;
        if (!count) {
          for (int j = 1; j <= n; ++j) {
            if (i == j) continue;
            if (((1 << (j - 1)) & ins) == 0) continue;
            dp[i][S] += dp[j][ins] * dp[i][S ^ ins];
          }
        } else {
          dp[i][S] += dp[i][S ^ ins] * dp[V][ins];
        }
      }
    }
  }
  printf("%lld\n", dp[1][(1 << n) - 1]);
  return 0;
}
