#include <bits/stdc++.h>
using namespace std;
const int N = 13;
const int M = 100 + 5;
const int S = (1 << N) + 5;
int n, m, q;
long long f[S][N];
long long g[S], dp[S];
int must[N][N];
int adj[N];
int con[M][3];
void solve() {
  cin >> n >> m >> q;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    must[u][v] = true;
    must[v][u] = true;
    adj[u] |= (1 << v);
    adj[v] |= (1 << u);
  }
  for (int i = 0; i < q; ++i) {
    cin >> con[i][0] >> con[i][1] >> con[i][2];
    con[i][0]--;
    con[i][1]--;
    con[i][2]--;
  }
  for (int s = 1; s < (1 << n); ++s) {
    for (int root = 0; root < n; ++root) {
      if (~s >> root & 1) continue;
      int subs = s - (1 << root);
      int valid = true;
      for (int 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 (int ns = subs; ns; ns = (ns - 1) & subs) {
        g[ns] = 0;
        for (int 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 (int tmpS = 1; tmpS < (1 << n); ++tmpS) {
        if ((subs & tmpS) != tmpS) continue;
        int sig = tmpS & (-tmpS);
        dp[tmpS] = 0;
        for (int 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;
}
int main() {
  solve();
  return 0;
}
