#include <bits/stdc++.h>
using namespace std;
int const N = 13;
int n, m, q;
long long dp[N][1 << N];
struct lca {
  int u, v, c;
};
struct edge {
  int u, v;
};
vector<edge> edges;
vector<lca> lcas;
inline bool valid(int mask, int sub, int u, int v) {
  if (!(mask & (1 << u)) || !(mask & (1 << v))) return false;
  if (bool(sub & (1 << u)) == bool(sub & (1 << v))) return false;
  return true;
}
inline bool ok(int root, int child, int mask, int sub) {
  for (auto ed : edges) {
    int u = ed.u, v = ed.v;
    if (!valid(mask, sub, u, v)) continue;
    if (root == v) swap(u, v);
    if (root != u || child != v) return false;
  }
  for (auto l : lcas) {
    int u = l.u, v = l.v, c = l.c;
    if (!valid(mask, sub, u, v)) continue;
    if (c != root) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> q;
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    edges.push_back({x, y});
  }
  for (int i = 0; i < q; i++) {
    int x, y, c;
    cin >> x >> y >> c;
    x--, y--, c--;
    if (x == y && x != c) return cout << "0\n", 0;
    lcas.push_back({x, y, c});
  }
  for (int i = 0; i < n; i++) dp[i][1 << i] = 1;
  for (int mask = 1; mask < (1 << n); mask++) {
    for (int root = 0; root < n; root++) {
      if (!(mask & (1 << root))) continue;
      int p = -1;
      for (int i = 0; i < n; i++)
        if ((mask & (1 << i)) && i != root) p = i;
      if (p == -1) continue;
      for (int sub = mask & (mask - 1); sub > 0; sub = (sub - 1) & mask) {
        if ((sub & (1 << root)) || !(sub & (1 << p))) continue;
        for (int child = 0; child < n; child++)
          if (ok(root, child, mask, sub))
            dp[root][mask] += dp[child][sub] * dp[root][mask ^ sub];
      }
    }
  }
  cout << dp[0][(1 << n) - 1] << endl;
}
