#include <bits/stdc++.h>
using namespace std;
const long long base = 1E9 + 7;
const int N = 100 + 10;
const int M = 1000 + 10;
const double ep = 0.0000001;
struct Ship {
  int x, a, f;
  Ship(int x, int a, int f) {
    this->x = x;
    this->a = a;
    this->f = f;
  }
};
struct Base {
  int x, d;
  Base(int x, int d) {
    this->x = x;
    this->d = d;
  }
};
int n, m;
vector<int> edges[N];
int path[N][N];
long long s, b, k, h;
Ship* ships[M];
Base* bases[M];
vector<int> a[M];
int Visited[M], t = 0;
int Assigned[M];
vector<int> dummy;
bool inDummy[N];
void computePath(int o) {
  dummy.clear();
  for (int i = 1; i <= n; i++) inDummy[i] = false;
  dummy.push_back(o);
  inDummy[o] = true;
  int i = 0;
  while (i < dummy.size()) {
    int cur = dummy[i];
    for (int node : edges[cur])
      if (!inDummy[node]) {
        inDummy[node] = true;
        path[o][node] = path[o][cur] + 1;
        dummy.push_back(node);
      }
    i++;
  }
}
bool visit(int u) {
  if (Visited[u] != t)
    Visited[u] = t;
  else
    return false;
  for (int v : a[u])
    if (!Assigned[v] || visit(Assigned[v])) {
      Assigned[v] = u;
      return true;
    }
  return false;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) computePath(i);
  cin >> s >> b >> k >> h;
  for (int i = 0; i < s; i++) {
    int x, a, f;
    cin >> x >> a >> f;
    ships[i] = new Ship(x, a, f);
  }
  for (int i = 0; i < b; i++) {
    int x, d;
    cin >> x >> d;
    bases[i] = new Base(x, d);
  }
  for (int i = 0; i < s; i++) {
    for (int j = 0; j < b; j++)
      if (ships[i]->a >= bases[j]->d &&
          path[ships[i]->x][bases[j]->x] <= ships[i]->f)
        a[i + 1].push_back(j + 1);
  }
  long long Count = 0;
  for (int i = 1; i <= s; i++) {
    t++;
    Count += visit(i);
  }
  long long res = 1e12;
  for (long long i = 0; i <= s; i++)
    res = min(res, i * h + min(s - i, Count) * k);
  cout << res;
  return 0;
}
