#include <bits/stdc++.h>
using namespace std;
int n, m, q, x[13], y[13], a[105], b[105], c[105];
long long f[13][1 << 13], g[13][1 << 13];
bool in(int v, int st) { return st & (1 << v); }
long long calc(int, int);
long long calcG(int v, int st) {
  for (int i = 0; i < m; i++)
    if (in(x[i], st) != in(y[i], st))
      if ((x[i] != v) && (y[i] != v)) return 0;
  for (int i = 0; i < q; i++)
    if (!in(c[i], st)) {
      if (in(a[i], st) && in(b[i], st)) return 0;
    } else {
      if (((!in(a[i], st)) || (!in(b[i], st))) && (c[i] != v)) return 0;
    }
  if (g[v][st] > 0) return g[v][st];
  return g[v][st] = calc(v, st);
}
long long calcF(int v, int st, int p) {
  for (int i = 0; i < m; i++)
    if (in(x[i], st) != in(y[i], st))
      if ((x[i] != v && x[i] != p) || (y[i] != v && y[i] != p)) return 0;
  for (int i = 0; i < q; i++)
    if (!in(c[i], st)) {
      if (in(a[i], st) && in(b[i], st)) return 0;
    } else {
      if ((!in(a[i], st)) || (!in(b[i], st))) return 0;
    }
  if (f[v][st] > 0) return f[v][st];
  return f[v][st] = calc(v, st);
}
long long calc(int v, int st) {
  int stt = st ^ (1 << v);
  if (stt == 0) return 1;
  long long ans = 0;
  for (int i = stt; i > 0; i = (i - 1) & stt) {
    if ((i & stt & (-stt)) == 0) continue;
    for (int u = 0; u < n; u++)
      if (in(u, i)) ans += calcF(u, i, v) * calcG(v, st ^ i);
  }
  return ans;
}
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < m; i++) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }
  for (int i = 0; i < q; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--, c[i]--;
  }
  cout << calcF(0, (1 << n) - 1, -1);
}
