#include <bits/stdc++.h>
using namespace std;
long long p[15], n, dp[14][2000000];
vector<pair<int, int> > lca[15];
vector<int> graph[15];
bool validedge(int i, int j, int mask) {
  for (int f1 = 0; f1 < graph[j].size(); f1++)
    if ((mask / p[graph[j][f1]]) % 3 == 2 && i != graph[j][f1]) return 0;
  return 1;
}
bool validlca1(int i, int mask) {
  for (int f = 0; f < lca[i].size(); f++) {
    int a = mask / p[lca[i][f].first] % 3;
    int b = mask / p[lca[i][f].second] % 3;
    if (lca[i][f].first == i) a = 0;
    if (lca[i][f].second == i) b = 0;
    if (a + b >= 1) return 0;
  }
  return 1;
}
bool validlca(int i, int mask) {
  for (int f = 0; f < lca[i].size(); f++) {
    int a = mask / p[lca[i][f].first] % 3;
    int b = mask / p[lca[i][f].second] % 3;
    if (lca[i][f].first == i) a = 0;
    if (lca[i][f].second == i) b = 0;
    if (a == 1 && b == 1) return 0;
  }
  return 1;
}
long long bt(int i, int mask, int j) {
  if (mask == p[n] - 1) return 1;
  if (dp[i][mask] != -1) return dp[i][mask];
  bool one = 0;
  for (int f = 0; f < n; f++)
    if (mask / p[f] % 3 == 1) one = 1;
  if (!one)
    for (int f = 0; f < n; f++)
      if (mask / p[f] % 3 == 0)
        if (validlca(i, mask + p[f]))
          return dp[i][mask] = bt(i, mask + p[f], j);
        else
          return dp[i][mask] = 0;
  int mask2 = mask;
  int mask3 = mask;
  for (int f = 0; f < n; f++) {
    if ((mask2 / p[f]) % 3 == 1) mask2 += p[f];
    if ((mask3 / p[f]) % 3 == 0)
      mask3 += 2 * p[f];
    else if ((mask3 / p[f]) % 3 == 1)
      mask3 -= p[f];
  }
  long long ret = 0;
  for (int f = 0; f < n; f++)
    if ((mask / p[f]) % 3 == 1 && validedge(i, f, mask) &&
        validlca1(f, mask3 + 2 * p[f]))
      ret = (ret + bt(f, mask3 + 2 * p[f], 0) * bt(i, mask2, 0));
  for (int f = j; f < n; f++)
    if (mask / p[f] % 3 == 0 && validlca(i, mask + p[f]))
      ret = (ret + bt(i, mask + p[f], f + 1));
  return dp[i][mask] = ret;
}
int main() {
  int x = 1;
  for (int f = 0; f < 15; f++) {
    p[f] = x;
    x *= 3;
  }
  cin >> n;
  int m, q;
  cin >> m >> q;
  for (int f = 0; f < m; f++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  m = q;
  memset(dp, -1, sizeof dp);
  for (int f = 0; f < m; f++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c--;
    lca[c].push_back(make_pair(a, b));
  }
  cout << bt(0, 2, 0) << endl;
}
