#include <bits/stdc++.h>
using namespace std;
int n, m, ns, nb;
long long costReal, costDummy;
struct spaceShip {
  int location, attack, fuel;
};
spaceShip sp[100001 + 1];
int f[100001 + 1], q[100001 + 1], visited[100001 + 1], p[2][100001 + 1], timer,
    check[100001 + 1];
vector<int> a[100001 + 1], canGo[100001 + 1];
struct base {
  int defense, position;
};
vector<base> defense[100001 + 1];
void readInput() {
  int x, y;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  cin >> ns >> nb >> costReal >> costDummy;
  for (int i = 1; i <= ns; i++) {
    cin >> sp[i].location >> sp[i].attack >> sp[i].fuel;
  }
  base xx;
  for (int i = 0; i < nb; i++) {
    cin >> x >> y;
    xx.defense = y;
    xx.position = i + 1;
    defense[x].push_back(xx);
  }
}
void bfs(spaceShip k, int position) {
  for (int i = 0; i <= n; i++) f[i] = -1;
  int l = 0, r = 0;
  q[l] = k.location;
  f[q[l]] = 0;
  int x, y;
  y = k.location;
  for (int j = 0; j < defense[y].size(); j++) {
    if (k.attack >= defense[y][j].defense)
      canGo[position].push_back(defense[y][j].position);
  }
  while (l <= r) {
    x = q[l];
    l++;
    for (int i = 0; i < a[x].size(); i++) {
      y = a[x][i];
      if (f[y] == -1 && f[x] < k.fuel) {
        q[++r] = y;
        f[y] = f[x] + 1;
        for (int j = 0; j < defense[y].size(); j++) {
          if (k.attack >= defense[y][j].defense)
            canGo[position].push_back(defense[y][j].position);
        }
      }
    }
  }
}
bool visit(int k) {
  if (visited[k] == timer) return false;
  visited[k] = timer;
  int x;
  for (int i = 0; i < canGo[k].size(); i++) {
    x = canGo[k][i];
    if (p[1][x] == 0 || visit(p[1][x]) == true) {
      p[0][i] = x;
      p[1][x] = k;
      return true;
    }
  }
  return false;
}
void solve() {
  int x, totalPair = 0;
  for (int i = 1; i <= ns; i++) {
    bfs(sp[i], i);
    for (int j = 0; j < canGo[i].size(); j++) {
      x = canGo[i][j];
      if (p[1][x] == 0) {
        p[0][i] = x;
        p[1][x] = i;
        totalPair++;
        break;
      }
    }
  }
  timer = 1;
  for (int i = 1; i <= ns; i++) {
    if (p[0][i] == 0) {
      timer++;
      totalPair += visit(i);
    }
  }
  costReal *= totalPair;
  costDummy *= ns;
  cout << min(costDummy, costReal);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  readInput();
  solve();
}
