#include <bits/stdc++.h>
using namespace std;
int n, m;
int f[50][50], mn[50], mx[50];
const int INF = 1e9;
int gm, gg, sm, ss;
long long d[51][51] = {}, nd[51][51];
bool cang[50], cans[50], canb[50];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (int)(n); ++i)
    for (int j = 0; j < (int)(n); ++j) f[i][j] = INF;
  for (int i = 0; i < (int)(n); ++i) f[i][i] = 0;
  for (int i = 0; i < (int)(m); ++i) {
    int from, to, w;
    scanf("%d%d%d", &from, &to, &w), --from, --to;
    f[from][to] = min(f[from][to], w);
    f[to][from] = min(f[to][from], w);
  }
  scanf("%d%d%d%d", &gm, &gg, &sm, &ss);
  for (int k = 0; k < (int)(n); ++k)
    for (int i = 0; i < (int)(n); ++i)
      for (int j = 0; j < (int)(n); ++j) {
        f[i][j] = min(f[i][j], f[i][k] + f[k][j]);
      }
  for (int i = 0; i < (int)(n); ++i) {
    mn[i] = INF, mx[i] = -INF;
    for (int j = 0; j < (int)(n); ++j)
      if (i != j) {
        mn[i] = min(mn[i], f[i][j]);
        mx[i] = max(mx[i], f[i][j]);
      }
  }
  long long ans = 0;
  for (int gco = 0; gco < (int)(n); ++gco)
    for (int bco = 0; bco < (int)(n); ++bco)
      if (mn[gco] < mx[bco] || (mn[gco] == mx[bco] && gco < bco)) {
        if (gco == bco) continue;
        bool ok = true;
        for (int i = 0; i < (int)(n); ++i) {
          if (i == gco) {
            cang[i] = true;
            cans[i] = canb[i] = false;
          } else if (i == bco) {
            canb[i] = true;
            cang[i] = cans[i] = false;
          } else {
            cang[i] = mn[i] < mn[gco] || (mn[i] == mn[gco] && i < gco);
            canb[i] = mx[i] > mx[bco] || (mx[i] == mx[bco] && i > bco);
            cans[i] = false;
            for (int j = 0; j < (int)(n); ++j)
              if (j != i &&
                  (f[i][j] > mn[gco] || (f[i][j] == mn[gco] && i > gco)) &&
                  (f[i][j] < mx[bco] || (f[i][j] == mx[bco] && i < bco))) {
                cans[i] = true;
                break;
              }
            if (!cang[i] && !cans[i] && !canb[i]) {
              ok = false;
              break;
            }
          }
        }
        if (!ok) continue;
        memset(d, 0, sizeof d);
        d[0][0] = 1;
        for (int i = 0; i < (int)(n); ++i) {
          memset(nd, 0, sizeof nd);
          for (int g = 0; g < (int)(gg + 1); ++g)
            for (int s = 0; s < (int)(ss + 1); ++s)
              if (d[g][s] != 0) {
                if (cang[i]) {
                  nd[g + 1][s] += d[g][s];
                }
                if (cans[i]) {
                  nd[g][s + 1] += d[g][s];
                }
                if (canb[i]) {
                  nd[g][s] += d[g][s];
                }
              }
          memcpy(d, nd, sizeof nd);
        }
        for (int g = gm; g <= gg; ++g)
          for (int s = sm; s <= ss; ++s) {
            ans += d[g][s];
          }
        d[gg][ss] -= ans;
      }
  cout << ans << endl;
  return 0;
}
