#include <bits/stdc++.h>
using namespace std;
const int N = 15;
const int M = 101;
int n, m, q;
int x[N], y[N], a[M], b[M], c[M];
long long dp1[N][1 << N], dp2[N][1 << N];
bool in(int x, int mask) { return (mask & (1 << x)) > 0; }
long long calc(int v, int mask);
long long go1(int v, int mask, int p) {
  for (int i = 0; i < m; i++) {
    if (in(x[i], mask) != in(y[i], mask)) {
      if ((x[i] != v and x[i] != p) or (y[i] != v and y[i] != p)) return 0;
    }
  }
  for (int i = 0; i < q; i++) {
    if (!in(c[i], mask)) {
      if (in(a[i], mask) and in(b[i], mask)) return 0;
    } else if (!in(a[i], mask) or !in(b[i], mask))
      return 0;
  }
  if (dp1[v][mask] > 0) return dp1[v][mask];
  return dp1[v][mask] = calc(v, mask);
}
long long go2(int v, int mask) {
  for (int i = 0; i < m; i++) {
    if (in(x[i], mask) != in(y[i], mask)) {
      if (x[i] != v and y[i] != v) return 0;
    }
  }
  for (int i = 0; i < q; i++) {
    if (!in(c[i], mask)) {
      if (in(a[i], mask) and in(b[i], mask)) return 0;
    } else if ((!in(a[i], mask) or !in(b[i], mask)) and c[i] != v)
      return 0;
  }
  if (dp2[v][mask] > 0) return dp2[v][mask];
  return dp2[v][mask] = calc(v, mask);
}
long long calc(int v, int mask) {
  int nmask = mask ^ (1 << v);
  if (nmask == 0) return 1;
  long long ret = 0;
  for (int i = nmask; i > 0; i = ((i - 1) & nmask)) {
    if ((i & (nmask & (-nmask))) == 0) continue;
    for (int j = 0; j < n; j++) {
      if (in(j, i)) {
        ret += go1(j, i, v) * go2(v, mask ^ i);
      }
    }
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x[i], &y[i]);
    x[i]--, y[i]--;
  }
  for (int i = 0; i < q; i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    a[i]--, b[i]--, c[i]--;
  }
  cout << go1(0, (1 << n) - 1, -1) << endl;
  return 0;
}
