#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
int n, m, q, G[13];
long long dp[1 << 13 | 5][13];
struct Arrow {
  int u, v, anc;
} Q[105];
int main() {
  int tpq;
  cin >> n >> m >> tpq;
  for (int i = (1), iend = (m); i <= iend; ++i) {
    int u, v;
    cin >> u >> v, u--, v--;
    G[u] |= 1 << v, G[v] |= 1 << u;
  }
  for (int i = (0), iend = (tpq - 1); i <= iend; ++i) {
    int u, v, anc;
    cin >> u >> v >> anc;
    u--, v--, anc--;
    if (u == v && u != anc) return puts("0"), 0;
    if (u != v) Q[q++] = {u, v, anc};
  }
  int all = (1 << n) - 1;
  for (int i = (0), iend = (n - 1); i <= iend; ++i) dp[1 << i][i] = 1;
  for (int S = (0), Send = (all); S <= Send; ++S)
    if (__builtin_popcount(S) > 1)
      for (int i = (0), iend = (n - 1); i <= iend; ++i)
        if ((S >> i & 1) && ((~S & 1) || !i)) {
          int tp = S ^ (1 << i), lw = tp & -tp;
          for (int T = tp; T; T = (T - 1) & tp)
            if ((T & lw) == lw)
              for (int j = (0), jend = (n - 1); j <= jend; ++j)
                if (T >> j & 1) {
                  if (((T | 1 << i) & G[j]) != G[j]) continue;
                  if ((T & G[i]) && (T & G[i]) != (1 << j)) continue;
                  bool flg = 1;
                  for (int _ = (0), _end = (q - 1); _ <= _end; ++_) {
                    if ((T >> Q[_].anc & 1) && ((S ^ T) >> Q[_].u & 1) &&
                        ((S ^ T) >> Q[_].v & 1)) {
                      flg = 0;
                      break;
                    }
                    if (((tp ^ T) >> Q[_].anc & 1) &&
                        ((T | 1 << i) >> Q[_].u & 1) &&
                        ((T | 1 << i) >> Q[_].v & 1)) {
                      flg = 0;
                      break;
                    }
                    if (((S ^ T) >> Q[_].u & 1) && (T >> Q[_].v & 1) &&
                        Q[_].anc != i) {
                      flg = 0;
                      break;
                    }
                    if (((S ^ T) >> Q[_].v & 1) && (T >> Q[_].u & 1) &&
                        Q[_].anc != i) {
                      flg = 0;
                      break;
                    }
                  }
                  if (!flg) continue;
                  dp[S][i] += dp[S ^ T][i] * dp[T][j];
                }
        }
  cout << dp[all][0] << endl;
  return 0;
}
