#include <bits/stdc++.h>
using namespace std;
const long long N = 15;
const long long M = 109;
const long long Maxmask = (1 << N) + 9;
long long n, m, q, f[Maxmask][N], g[Maxmask], dp[Maxmask], must[N][N], adj[N],
    con[M][3];
void solve() {
  for (long long s = 1; s < (1 << n); s++) {
    for (long long root = 0; root < n; ++root) {
      if (~s >> root & 1) continue;
      long long subs = s - (1 << root);
      long long valid = true;
      for (long long i = 0; i < q; ++i) {
        if (s >> con[i][2] & 1) {
          if (~s >> con[i][0] & 1) {
            valid = false;
          }
          if (~s >> con[i][1] & 1) {
            valid = false;
          }
        } else {
          if ((s >> con[i][0] & 1) && (s >> con[i][1] & 1)) {
            valid = false;
          }
        }
      }
      if (!valid) continue;
      if (subs == 0) {
        f[s][root] = 1;
        continue;
      }
      dp[0] = 1;
      for (long long ns = subs; ns; ns = (ns - 1) & subs) {
        g[ns] = 0;
        for (long long nroot = 0; nroot < n; ++nroot) {
          if (~ns >> nroot & 1) continue;
          if ((adj[nroot] & (ns + (1 << root))) != adj[nroot]) {
            continue;
          }
          g[ns] += f[ns][nroot];
        }
      }
      for (long long tmpS = 1; tmpS < (1 << n); ++tmpS) {
        if ((subs & tmpS) != tmpS) continue;
        long long sig = tmpS & (-tmpS);
        dp[tmpS] = 0;
        for (long long ns = tmpS; ns; ns = (ns - 1) & tmpS) {
          if (~ns & sig) continue;
          dp[tmpS] += dp[tmpS - ns] * g[ns];
        }
      }
      f[s][root] = dp[subs];
    }
  }
  cout << f[(1 << n) - 1][0] << endl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> q;
  long long u, v;
  for (long long i = 1; i <= m; i++) {
    cin >> u >> v;
    --u, --v;
    must[u][v] = true;
    must[v][u] = true;
    adj[u] |= (1 << v);
    adj[v] |= (1 << u);
  }
  for (long long i = 0; i < q; i++) {
    cin >> con[i][0] >> con[i][1] >> con[i][2];
    con[i][0]--;
    con[i][1]--;
    con[i][2]--;
  }
  solve();
  return 0;
}
