#include <bits/stdc++.h>
using namespace std;
const long long MAX_N = 3e3 + 3, MAX_M = 3e6 + 19, inf = 1e9 + 7;
long long n, m, s, b, k, h, ans, V, U;
long long dis[MAX_N][MAX_N];
pair<long long, long long> edge[MAX_M];
long long ind;
bool rev[MAX_M];
bool mark[MAX_N];
long long x[MAX_N], a[MAX_N], f[MAX_N], X[MAX_N], d[MAX_N];
vector<long long> G[MAX_N];
bool dfs(long long v) {
  mark[v] = true;
  if (v == U) return true;
  for (long long id : G[v]) {
    if (!rev[id] && edge[id].first != v) continue;
    if (rev[id] && edge[id].second != v) continue;
    long long u = (rev[id] ? edge[id].first : edge[id].second);
    if (mark[u]) continue;
    if (dfs(u)) {
      rev[id] ^= 1;
      return true;
    }
  }
  return false;
}
int main() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++) dis[i][j] = (i == j ? 0 : inf);
  for (long long i = 0; i < m; i++) {
    long long v, u;
    cin >> v >> u;
    v--, u--;
    dis[v][u] = dis[u][v] = min(dis[v][u], 1LL);
  }
  for (int t = 0; t < n; t++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        dis[i][j] = min(dis[i][j], dis[i][t] + dis[t][j]);
  cin >> s >> b >> k >> h;
  ans = h * s;
  for (long long i = 0; i < s; i++) cin >> x[i] >> a[i] >> f[i];
  for (long long i = 0; i < b; i++) cin >> X[i] >> d[i];
  for (long long i = 0; i < s; i++)
    for (long long j = 0; j < b; j++)
      if (dis[x[i] - 1][X[j] - 1] <= f[i] && d[j] <= a[i]) {
        edge[ind] = {i, (s + j)};
        G[i].push_back(ind);
        G[s + j].push_back(ind);
        ind++;
      }
  V = s + b, U = s + b + 1;
  for (long long i = 0; i < s; i++) {
    edge[ind] = {V, i};
    G[V].push_back(ind);
    G[i].push_back(ind);
    ind++;
  }
  for (long long i = 0; i < b; i++) {
    edge[ind] = {s + i, U};
    G[s + i].push_back(ind);
    G[U].push_back(ind);
    ind++;
  }
  long long res = 0;
  while (dfs(V)) {
    memset(mark, 0, sizeof mark);
    res++;
  }
  ans = min(ans, res * k);
  cout << ans << "\n";
  return 0;
}
