#include <bits/stdc++.h>
using namespace std;
long long int ff[15][40000][15];
int maskk[15];
bool ok[15][40000][15];
int need[15], n;
vector<int> forbit[15];
long long int f(int x, int mask, int pre) {
  if (ok[x][mask][pre]++) return ff[x][mask][pre];
  long long int &ans = ff[x][mask][pre];
  if (mask == 0) return ans = 1;
  for (int submask = mask; submask > 0; submask--) {
    submask &= mask;
    bool ch = false;
    if (submask == 0) break;
    if (__builtin_popcount(submask & maskk[x]) > 1) continue;
    for (int i = 0; i < forbit[x].size(); i++) {
      if ((forbit[x][i] & submask) == forbit[x][i]) {
        ch = true;
        break;
      }
    }
    if (ch) continue;
    for (int i = pre + 1; i < n; i++) {
      if (submask & (1 << i) && ((maskk[i] & (submask | (1 << x))) == maskk[i]))
        if (__builtin_popcount((submask ^ (1 << i)) & maskk[x]) == 0 &&
            (need[i] & submask) == need[i]) {
          ans = (ans +
                 1LL * f(i, submask ^ (1 << i), 0) * f(x, mask ^ submask, i));
        }
    }
  }
  return ans;
}
void read() {
  int i, q, m, x, y;
  scanf("%d %d %d", &n, &m, &q);
  for (i = 1; i <= m; i++) {
    scanf("%d %d", &x, &y);
    x--;
    y--;
    maskk[x] |= (1 << y);
    maskk[y] |= (1 << x);
  }
  for (i = 1; i <= q; i++) {
    scanf("%d %d %d", &x, &y, &m);
    x--;
    y--;
    m--;
    forbit[m].push_back((1 << x) | (1 << y));
    need[m] |= (1 << x) | (1 << y);
  }
  printf("%lld\n", f(0, (1 << n) - 2, 0));
}
int main() { read(); }
