#include <bits/stdc++.h>
using namespace std;
const int N = 15;
int waitRoot;
int n, m, q;
int x, y, z;
int bits[1 << N];
int forWhoRoot[N];
int haveEdges[N];
vector<int> g[N];
bool was[N][1 << N];
int whoFirst[1 << N];
long long f[N][1 << N];
vector<pair<int, int> > lca[N];
int getBits(int x) {
  if (bits[x] == 0) {
    int y = x;
    while (y > 0) {
      bits[x] += (y % 2);
      y /= 2;
    }
  }
  return bits[x];
}
bool isValid(int root, int newRoot, int mask) {
  for (size_t i = 0; i < lca[root].size(); i++) {
    int v1 = lca[root][i].first;
    int v2 = lca[root][i].second;
    if ((mask & (1 << v1)) != 0 && (mask & (1 << v2)) != 0) {
      return false;
    }
  }
  int in_common = (forWhoRoot[newRoot] & mask);
  if (in_common != forWhoRoot[newRoot]) {
    return false;
  }
  return true;
}
bool isValid2(int root, int m1, int m2) {
  m2 -= (1 << root);
  for (int i = 0; i < n; i++) {
    if ((m1 & (1 << i)) != 0 && i != root) {
      int in_common = (haveEdges[i] & m2);
      if (getBits(in_common) > 0) {
        return false;
      }
    }
  }
  return true;
}
int getFirst(int mask) {
  if (whoFirst[mask] != -1) {
    return whoFirst[mask];
  }
  int i = 0;
  int res = 0;
  while (mask > 0) {
    if (mask % 2 == 1) {
      res = max(res, i);
    }
    mask /= 2;
    ++i;
  }
  whoFirst[mask] = res;
  return res;
}
long long calc(int root, int mask) {
  if (getBits(mask) == 1) {
    return 1LL;
  }
  if (was[root][mask]) {
    return f[root][mask];
  }
  f[root][mask] = 0LL;
  int newMainMask = mask - (1 << root);
  int curMask = newMainMask;
  int ff = getFirst(newMainMask);
  while (curMask > 0) {
    if ((curMask & (1 << ff)) == 0) {
      curMask = ((curMask - 1) & newMainMask);
      continue;
    }
    if (curMask == 12 && root == 0) {
      curMask = 12;
    }
    for (int newRoot = 0; newRoot < n; newRoot++) {
      if (newRoot != root && (curMask & (1 << newRoot)) != 0) {
        int in_common = (curMask & haveEdges[root]);
        if (getBits(in_common) > 1) {
          continue;
        }
        if (getBits(in_common) == 1) {
          int result_common = (in_common & (1 << newRoot));
          if (result_common == 0) {
            continue;
          }
        }
        if (!isValid(root, newRoot, curMask)) {
          continue;
        }
        if (!isValid2(root, curMask, mask ^ curMask)) {
          continue;
        }
        f[root][mask] +=
            (1LL * calc(newRoot, curMask) * calc(root, mask ^ curMask));
      }
    }
    curMask = ((curMask - 1) & newMainMask);
  }
  was[root][mask] = true;
  return f[root][mask];
}
int main() {
  int maxMask = (1 << 13);
  for (int i = 0; i < maxMask; i++) whoFirst[i] = -1;
  scanf("%d%d%d", &n, &m, &q);
  --waitRoot;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
    haveEdges[x] |= (1 << y);
    haveEdges[y] |= (1 << x);
  }
  for (int i = 1; i <= q; i++) {
    scanf("%d%d%d", &x, &y, &z);
    --x;
    --y;
    --z;
    lca[z].push_back(make_pair(x, y));
    forWhoRoot[z] |= (1 << x);
    forWhoRoot[z] |= (1 << y);
  }
  cout << calc(0, (1 << n) - 1) << endl;
  return 0;
}
