#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC optimize("fast-math")
using namespace std;
const int DEBUG = 0;
mt19937 gen(
    (unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
#pragma comment(linker, "/STACK:16777216")
struct base {
  int v, def;
};
struct plane {
  int v, atack, fuel;
};
const int N = 2000;
int g[100][100];
int canBeat[N][N];
int pl[N];
int pr[N];
int used[N];
int dfs(int v) {
  if (used[v]) return 0;
  used[v] = 1;
  for (int i = 0; i < N; i++) {
    if (canBeat[v][i] && (pr[i] == -1 || dfs(pr[i]))) {
      pl[v] = i;
      pr[i] = v;
      return 1;
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(cout.fixed);
  cout.precision(12);
  auto START_TIME = chrono::high_resolution_clock::now();
  int nv, ne;
  cin >> nv >> ne;
  for (int i = 0; i < nv; i++) {
    for (int j = 0; j < nv; j++) {
      if (i != j) g[i][j] = 2 * 1000000000;
    }
  }
  for (int i = 0; i < ne; i++) {
    int s, e;
    cin >> s >> e;
    g[--s][--e] = 1;
    g[e][s] = 1;
  }
  for (int k = 0; k < nv; k++) {
    for (int i = 0; i < nv; i++) {
      for (int j = 0; j < nv; j++) {
        if (g[i][k] < 2 * 1000000000 && g[k][j] < 2 * 1000000000)
          g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  int nPlane, nBase;
  long long costBeat, costCreate;
  cin >> nPlane >> nBase >> costBeat >> costCreate;
  vector<plane> planes(nPlane);
  for (int i = 0; i < nPlane; i++) {
    cin >> planes[i].v >> planes[i].atack >> planes[i].fuel;
    --planes[i].v;
  }
  vector<base> bases(nBase);
  for (int i = 0; i < nBase; i++) {
    cin >> bases[i].v >> bases[i].def;
    --bases[i].v;
    for (int j = 0; j < nPlane; j++) {
      if (g[bases[i].v][planes[j].v] <= planes[j].fuel &&
          bases[i].def <= planes[j].atack) {
        canBeat[j][i] = 1;
      }
    }
  }
  fill(pl, pl + nPlane, -1);
  fill(pr, pr + nBase, -1);
  while (1) {
    fill(used, used + nPlane, 0);
    int stop = 1;
    for (int i = 0; i < nPlane; i++) {
      if (pl[i] == -1 && dfs(i)) {
        stop = 0;
      }
    }
    if (stop) break;
  }
  long long res = 1000000000000000000LL;
  long long cost = 0;
  int nAttack = 0, nSeek = 0;
  for (int i = 0; i < nPlane; i++) {
    if (pl[i] == -1)
      nSeek++;
    else
      nAttack++;
  }
  cost = nAttack * costBeat;
  res = cost;
  for (int fake = 0; fake < nPlane; fake++) {
    if (nSeek > 0) {
      cost += costCreate;
      nSeek--;
    } else {
      cost -= costBeat;
      cost += costCreate;
    }
    res = min(res, cost);
  }
  cout << res;
  return 0;
}
