#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
template <class U, class T>
void Max(U &first, T second) {
  if (first < second) first = second;
}
template <class U, class T>
void Min(U &first, T second) {
  if (first > second) first = second;
}
template <class T>
void add(int &a, T b) {
  a = (a + b) % 1000000007;
}
inline int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
int pow(int a, int b) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % 1000000007;
    a = 1LL * a * a % 1000000007;
    b >>= 1;
  }
  return ans;
}
int pow(int a, int b, int c) {
  int ans = 1;
  while (b) {
    if (b & 1) ans = 1LL * ans * a % c;
    a = 1LL * a * a % c;
    b >>= 1;
  }
  return ans;
}
int c[101][101];
pair<int, int> b[1001];
pair<int, pair<int, int> > a[1001];
vector<int> g[1001];
int p[1001], vis[1001];
int find(int u) {
  for (auto &v : g[u]) {
    if (vis[v]) continue;
    vis[v] = 1;
    if (p[v] == -1 || find(p[v])) {
      p[v] = u;
      return 1;
    }
  }
  return 0;
}
int main() {
  int T, ca = 0, k, i, j, n, m = 0, K;
  scanf("%d%d", &n, &m);
  memset(c, 63, sizeof(c));
  while (m--) {
    scanf("%d%d", &i, &j);
    i--, j--;
    c[i][j] = c[j][i] = 1;
  }
  for (int i = 0; i < n; i++) c[i][i] = 0;
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) Min(c[i][j], c[i][k] + c[k][j]);
    }
  }
  int S, B, H;
  scanf("%d%d%d%d", &S, &B, &K, &H);
  for (int i = 0; i < S; i++) {
    scanf("%d%d%d", &j, &k, &T);
    a[i] = {j - 1, {k, T}};
  }
  for (int i = 0; i < B; i++) {
    scanf("%d%d", &j, &k);
    b[i] = {j - 1, k};
  }
  memset(p, -1, sizeof(p));
  int sum = 0;
  for (int i = 0; i < S; i++) {
    int u = a[i].first;
    pair<int, int> o = a[i].second;
    for (int j = 0; j < B; j++) {
      int v = b[j].first;
      if (c[u][v] <= o.second && b[j].second <= o.first) {
        g[i].push_back(j);
      }
    }
  }
  for (int i = 0; i < S; i++) {
    memset(vis, 0, sizeof(vis));
    if (find(i)) sum++;
  }
  long long ans = min(1LL * S * H, 1LL * sum * K);
  printf("%lld\n", ans);
}
