#include <bits/stdc++.h>
using namespace std;
class edge {
 public:
  int u, v;
};
int first_bit(int x) {
  if (!x) return -1;
  for (int i = 0;; i++)
    if (x & (1 << i)) return i;
}
vector<vector<pair<int, int> > > lca(14);
vector<pair<int, int> > ed;
vector<int> e(14, 0), lca1(14, 0);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, q;
  cin >> n >> m >> q;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    ed.push_back({u, v});
    e[u] |= (1 << v);
    e[v] |= (1 << u);
  }
  for (int i = 0; i < q; i++) {
    int u, v, l;
    cin >> u >> v >> l;
    u--;
    v--;
    l--;
    lca[l].push_back({u, v});
    lca1[l] |= (1 << u) | (1 << v);
  }
  vector<vector<long long> > dp(n, vector<long long>((1 << n), 0));
  for (int i = 0; i < n; i++) dp[i][1 << i] = dp[i][0] = 1;
  for (int m = 1; m < (1 << n); m++) {
    for (int i = 0; i < n; i++) {
      if (!(m & (1 << i))) continue;
      for (int s = (m ^ (1 << i)); s; s = (s - 1) & (m ^ (1 << i))) {
        if (first_bit(m ^ (1 << i)) != first_bit(s)) continue;
        int rest = m ^ s ^ (1 << i);
        for (int r = 0; r < n; r++) {
          if (!(s & (1 << r))) continue;
          if (e[i] & (s ^ (1 << r))) continue;
          if ((lca1[r] | s) != s) continue;
          bool good = true;
          for (int j = 0; j < lca[i].size(); j++)
            if ((s & (1 << lca[i][j].first)) && (s & (1 << lca[i][j].second))) {
              good = false;
              break;
            }
          if (!good) continue;
          for (int j = 0; j < ed.size(); j++)
            if (((s & (1 << ed[j].first)) && (rest & (1 << ed[j].second))) ||
                ((s & (1 << ed[j].second)) && (rest & (1 << ed[j].first)))) {
              good = false;
              break;
            }
          if (!good) continue;
          if (good) {
            dp[i][m] += dp[i][m ^ s] * dp[r][s];
          }
        }
      }
    }
  }
  cout << dp[0][(1 << n) - 1] << "\n";
  return 0;
}
