#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e4 + 5;
long long n, m, q, mrk[20], dp[20][maxn], pw2[20];
vector<pair<pair<long long, long long>, long long>> lca;
vector<pair<long long, long long>> adj;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  pw2[0] = 1;
  for (long long i = 1; i < 15; i++) pw2[i] = (pw2[i - 1] * 2ll);
  cin >> n >> m >> q;
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    adj.push_back({u, v});
  }
  for (long long i = 0; i < q; i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    c--;
    if (a == b) {
      if (a != c) return cout << 0 << endl, 0;
      continue;
    }
    lca.push_back({{a, b}, c});
  }
  for (long long msk = 1; msk < pw2[n]; msk++) {
    vector<long long> vec;
    for (long long i = 0; i < n; i++) mrk[i] = 0;
    for (long long i = 0; i < n; i++) {
      if (pw2[i] & msk) vec.push_back(i);
    }
    if (vec.size() == 1) {
      dp[vec.back()][msk] = 1;
      continue;
    }
    for (long long rt : vec) {
      long long big = 0;
      for (long long i : vec) {
        if (i != rt) big = i;
      }
      long long msk2 = msk ^ pw2[rt] ^ pw2[big];
      mrk[rt] = 1;
      mrk[big] = 2;
      bool flag = 0;
      for (long long sub = msk2; !flag; sub = (msk2 & (sub - 1ll))) {
        if (sub == 0) flag = 1;
        if (dp[rt][msk2 ^ sub ^ pw2[rt]] == 0) continue;
        for (long long i = 0; i < n; i++) {
          if ((pw2[i] & msk2) == 0) continue;
          if (pw2[i] & sub)
            mrk[i] = 2;
          else
            mrk[i] = 1;
        }
        bool bl = 0;
        for (auto i : lca) {
          if (mrk[i.first.first] == 0) continue;
          if (mrk[i.first.second] == 0) continue;
          if (mrk[i.first.first] == mrk[i.first.second]) continue;
          if (i.second != rt) {
            bl = 1;
            break;
          }
        }
        if (bl) continue;
        long long num = 0, rt2 = 0;
        for (auto i : adj) {
          if (mrk[i.first] == 0) continue;
          if (mrk[i.second] == 0) continue;
          if (mrk[i.first] == mrk[i.second]) continue;
          if (mrk[i.second] == 1) {
            if (i.second != rt) {
              bl = 1;
              break;
            }
            rt2 = i.first;
            num++;
          }
          if (mrk[i.first] == 1) {
            if (i.first != rt) {
              bl = 1;
              break;
            }
            rt2 = i.second;
            num++;
          }
        }
        if (bl) continue;
        if (num > 1) continue;
        if (num == 0) {
          for (long long j : vec) {
            if (pw2[j] & msk2)
              dp[rt][msk] +=
                  dp[rt][msk2 ^ sub ^ pw2[rt]] * dp[j][sub ^ pw2[big]];
            if (j == big) {
              dp[rt][msk] +=
                  dp[rt][msk2 ^ sub ^ pw2[rt]] * dp[j][sub ^ pw2[big]];
            }
          }
        } else
          dp[rt][msk] += dp[rt][msk2 ^ sub ^ pw2[rt]] * dp[rt2][sub ^ pw2[big]];
      }
    }
  }
  cout << dp[0][pw2[n] - 1];
}
