#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
const long double eps = 0.0000000001;
const long long INF = 0x3fffffffffffffff;
long long n, m, k, a, b, c, dp[13][1 << 13];
struct lca {
  long long a, b, c;
} q[105];
struct edge {
  long long a, b;
} e[105];
long long dfs(long long root, long long now) {
  if (~dp[root][now]) {
    return dp[root][now];
  }
  if (1 << root == now) {
    return dp[root][now] = 1;
  }
  long long f = -1;
  for (long long i = 0; i < n; ++i) {
    if (((now ^ (1 << root)) & (1 << (i)))) {
      f = i;
      break;
    }
  }
  if (!~f) {
    return dp[root][now] = 0;
  }
  dp[root][now] = 0;
  for (long long i = now; i; i = (i - 1) & now) {
    if (((i) & (1 << (root)))) {
      continue;
    }
    if (!((i) & (1 << (f)))) {
      continue;
    }
    bool flag = false;
    for (long long j = 1; j <= k && !flag; ++j) {
      if (((i) & (1 << (q[j].c)))) {
        if (!(((i) & (1 << (q[j].a))) && ((i) & (1 << (q[j].b))))) {
          flag = true;
        }
      }
      if (((i) & (1 << (q[j].a))) && ((i) & (1 << (q[j].b)))) {
        if (!((i) & (1 << (q[j].c)))) {
          flag = true;
        }
      }
    }
    long long cnt = -1;
    for (long long j = 1; j <= m && !flag; ++j) {
      if (e[j].a == root) {
        if (((i) & (1 << (e[j].b)))) {
          if (~cnt) {
            flag = true;
          } else {
            cnt = e[j].b;
          }
        }
      } else if (e[j].b == root) {
        if (((i) & (1 << (e[j].a)))) {
          if (~cnt) {
            flag = true;
          } else {
            cnt = e[j].a;
          }
        }
      } else if ((((i) & (1 << (e[j].a))) != 0) ^
                 (((i) & (1 << (e[j].b))) != 0)) {
        flag = true;
      }
    }
    if (flag) {
      continue;
    } else if (~cnt) {
      dp[root][now] += dfs(cnt, i) * dfs(root, now ^ i);
    } else {
      for (long long j = 0; j < n; ++j) {
        if (((i) & (1 << (j)))) {
          dp[root][now] += dfs(j, i) * dfs(root, now ^ i);
        }
      }
    }
  }
  return dp[root][now];
}
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> m >> k;
  for (long long i = 1; i <= m; ++i) {
    cin >> e[i].a >> e[i].b;
    --e[i].a;
    --e[i].b;
  }
  for (long long i = 1; i <= k; ++i) {
    cin >> q[i].a >> q[i].b >> q[i].c;
    --q[i].a;
    --q[i].b;
    --q[i].c;
  }
  memset(dp, -1, sizeof(dp));
  cout << dfs(0, (1 << n) - 1) << endl;
  return 0;
}
