#include <bits/stdc++.h>
using namespace std;
const int maxn = 68;
int n, m, s1, s2, g1, g2, tot;
long long ans;
int g[maxn][maxn], best[maxn], worse[maxn];
long long f[maxn][maxn][maxn];
vector<int> score[maxn];
void init() {
  scanf("%d%d", &n, &m);
  int i, j, x, y, w;
  memset(g, 63, sizeof(g));
  for ((i) = (1); (i) <= (n); ++(i)) g[i][i] = 0;
  for ((i) = (1); (i) <= (m); ++(i)) {
    scanf("%d%d%d", &x, &y, &w);
    g[x][y] = g[y][x] = w;
  }
  scanf("%d%d%d%d", &g1, &g2, &s1, &s2);
}
void prework() {
  int i, j, k, tp;
  for ((k) = (1); (k) <= (n); ++(k))
    for ((i) = (1); (i) <= (n); ++(i))
      for ((j) = (1); (j) <= (n); ++(j))
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
  for ((i) = (1); (i) <= (n); ++(i))
    for ((j) = (1); (j) <= (n); ++(j))
      if (i != j) {
        score[i].push_back(g[i][j] * 60 + i);
      }
  for ((i) = (1); (i) <= (n); ++(i)) {
    sort(score[i].begin(), score[i].end());
    best[i] = score[i][0];
    worse[i] = score[i][n - 2];
  }
}
long long calc(int gold, int bronze) {
  int i, j, k, tp;
  bool cang, cans, canb;
  memset(f, 0, sizeof(f));
  f[0][0][0] = 1;
  for ((i) = (1); (i) <= (n); ++(i)) {
    cang = cans = canb = 0;
    if (i == gold)
      cang = 1;
    else {
      if (i == bronze)
        canb = 1;
      else {
        if (best[i] < best[gold]) cang = 1;
        if (worse[i] > worse[bronze]) canb = 1;
        for ((j) = 0; (j) < (score[i].size()); ++(j))
          if (score[i][j] > best[gold] && score[i][j] < worse[bronze]) cans = 1;
      }
    }
    for ((j) = (0); (j) <= (i - 1); ++(j))
      for ((k) = (0); (k) <= (i - 1 - j); ++(k)) {
        if (cang) f[i][j + 1][k] += f[i - 1][j][k];
        if (cans) f[i][j][k + 1] += f[i - 1][j][k];
        if (canb) f[i][j][k] += f[i - 1][j][k];
      }
  }
  long long cur = 0;
  for ((j) = (g1); (j) <= (g2); ++(j))
    for ((k) = (s1); (k) <= (s2); ++(k)) cur += f[n][j][k];
  return cur;
}
void work() {
  prework();
  int i, j, k, tp;
  ans = 0;
  for ((i) = (1); (i) <= (n); ++(i))
    for ((j) = (1); (j) <= (n); ++(j))
      if (i != j) ans += calc(i, j);
  cout << ans << endl;
}
int main() {
  init();
  work();
  return 0;
}
