#include <bits/stdc++.h>
using namespace std;
struct Query {
  int x, y, lca;
};
int n, m, q, x, y;
bool ok[8200];
Query v[105];
int adj[15];
long long dp[8200][15];
bool has(int mask, int b) { return (mask & (1 << b)) > 0; }
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> q;
  for (; m; m--) {
    cin >> x >> y, x--, y--;
    adj[x] |= (1 << y);
    adj[y] |= (1 << x);
  }
  for (int i = 1; i <= q; i++)
    cin >> v[i].x >> v[i].y >> v[i].lca, v[i].x--, v[i].y--, v[i].lca--;
  for (int i = 0; i < (1 << n); i++) {
    for (int j = 1; j <= q; j++) {
      bool a = has(i, v[j].x), b = has(i, v[j].y), c = has(i, v[j].lca);
      if ((a && b && !c) || (c && (!a || !b))) {
        ok[i] = 1;
        break;
      }
    }
  }
  for (int i = 1; i < (1 << n); i++) {
    for (int j = 0; j < n; j++) {
      if (has(i, j)) {
        int mask = (i ^ (1 << j)), lsb = (mask & -mask);
        if (!mask) {
          dp[i][j] = 1;
          continue;
        }
        for (int k = mask; k; k = (k - 1) & mask) {
          if ((k & lsb) && !ok[k]) {
            for (int l = 0; l < n; l++) {
              if (has(k, l) && (adj[l] & (k ^ (1 << j))) == adj[l])
                dp[i][j] += dp[i ^ k][j] * dp[k][l];
            }
          }
        }
      }
    }
  }
  cout << dp[(1 << n) - 1][0];
  return 0;
}
