#include <bits/stdc++.h>
using namespace std;
int e[13];
vector<int> l[13];
long long dp[13][1 << 13], sum[13][1 << 13];
int main() {
  int n, m, q, u, v, w;
  cin >> n >> m >> q;
  for (int i = 0; i < m; i++) {
    cin >> u >> v;
    u--;
    v--;
    e[u] |= 1 << v;
    e[v] |= 1 << u;
  }
  for (int i = 0; i < q; i++) {
    cin >> u >> v >> w;
    u--;
    v--;
    w--;
    l[w].push_back(1 << u | 1 << v);
  }
  for (int mask = 1; mask < (1 << n); mask++)
    for (int i = 0; i < n; i++)
      if (mask >> i & 1) {
        if ((mask & mask - 1) == 0)
          sum[i][mask] = 1;
        else {
          int k, child = mask ^ 1 << i;
          for (k = n - 1; ~child >> k & 1; k--)
            ;
          int rem = child ^ 1 << k;
          for (int v = rem;; v = v - 1 & rem) {
            int sub = v | 1 << k;
            for (int j = 0; j < n; j++)
              if (sub >> j & 1) {
                if (e[j] & ~(sub | 1 << i)) continue;
                int ok = 1;
                for (auto x : l[i])
                  if ((x & sub) == x) {
                    ok = 0;
                    break;
                  }
                if (!ok) continue;
                sum[i][mask] += dp[j][sub] * sum[i][mask ^ sub];
              }
            if (v == 0) break;
          }
        }
        int ok = 1;
        for (auto x : l[i])
          if (x & ~mask) {
            ok = 0;
            break;
          }
        if (ok) dp[i][mask] = sum[i][mask];
      }
  cout << dp[0][(1 << n) - 1] << endl;
  return 0;
}
