#include <bits/stdc++.h>
using namespace std;
struct $ {
  $() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} $;
const int N = 13;
int n, m, q;
vector<tuple<int, int>> edges;
int edgemask[N];
int triple[N][N];
int64_t dyn[1 << N][N];
int main() {
  cin >> n >> m >> q;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    edges.emplace_back(u, v);
    edgemask[u] |= 1 << v;
    edgemask[v] |= 1 << u;
  }
  bool fail = false;
  for (int i = 0; i < q; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    --a;
    --b;
    --c;
    if (triple[a][b] > 0 && triple[a][b] != c + 1) fail = true;
    if (a == b && a != c) fail = true;
    triple[a][b] = c + 1;
    triple[b][a] = c + 1;
  }
  if (!fail)
    for (int mask = 0; mask < (1 << n); ++mask)
      for (int root = 0; root < n; ++root)
        if (mask & (1 << root)) {
          if (mask == (1 << root)) {
            dyn[mask][root] = 1;
            continue;
          }
          int msk = mask ^ (1 << root);
          int low;
          for (low = 0; low < n; ++low)
            if (msk & (1 << low)) break;
          assert(low < n);
          for (int submask = msk; submask > 0; --submask, (submask &= msk)) {
            if (!(submask & (1 << low))) {
              submask &= ~((1 << low) - 1);
              if (!submask) break;
              continue;
            }
            for (int subroot = 0; subroot < n; ++subroot)
              if (submask & (1 << subroot)) {
                for (const auto &e : edges) {
                  int u, v;
                  tie(u, v) = e;
                  if (u == subroot && v == root) continue;
                  if (u == root && v == subroot) continue;
                  if ((submask & (1 << u)) && !(submask & (1 << v)) &&
                      (mask & (1 << v)))
                    goto nextsub;
                  if ((submask & (1 << v)) && !(submask & (1 << u)) &&
                      (mask & (1 << u)))
                    goto nextsub;
                }
                for (int a = 0; a < n; ++a)
                  if (submask & (1 << a))
                    for (int b = 0; b < n; ++b)
                      if (!(submask & (1 << b)) && (mask & (1 << b))) {
                        int c = triple[a][b];
                        if (c > 0 && c != root + 1) goto nextsub;
                      }
                dyn[mask][root] +=
                    dyn[submask][subroot] * dyn[mask ^ submask][root];
              nextsub:;
              }
          }
        }
  cout << dyn[(1 << n) - 1][0] << '\n';
  return 0;
}
