#include <bits/stdc++.h>
using namespace std;
const int maxn = 55;
const int inf = 1e9 + 10;
long long dp[maxn][maxn][maxn];
int dist[maxn][maxn], n, m, g1, g2, s1, s2;
bool gold[maxn], silver[maxn], copper[maxn];
int main() {
  for (int i = 0; i < maxn; i++)
    for (int j = 0; j < maxn; j++) dist[i][j] = i == j ? 0 : inf;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v, cost;
    scanf("%d%d%d", &u, &v, &cost);
    u--;
    v--;
    dist[u][v] = dist[v][u] = cost;
  }
  scanf("%d%d%d%d", &g1, &g2, &s1, &s2);
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++)
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) dist[i][j] = dist[i][j] * 100 + i;
  long long ans = 0;
  for (int P1 = 0; P1 < n; P1++)
    for (int P2 = 0; P2 < n; P2++)
      if (P1 != P2) {
        for (int i = 0; i < maxn; i++) gold[i] = silver[i] = copper[i] = false;
        int min_cost = inf, max_cost = 0;
        gold[P1] = copper[P2] = true;
        for (int i = 0; i < n; i++)
          if (i != P1) min_cost = min(min_cost, dist[P1][i]);
        for (int i = 0; i < n; i++)
          if (i != P2) max_cost = max(max_cost, dist[P2][i]);
        if (min_cost > max_cost) continue;
        for (int i = 0; i < n; i++)
          if (i != P1 && i != P2) {
            for (int j = 0; j < n; j++)
              if (i != j) {
                if (dist[i][j] < min_cost) gold[i] = true;
                if (min_cost < dist[i][j] && dist[i][j] < max_cost)
                  silver[i] = true;
                if (dist[i][j] > max_cost) copper[i] = true;
              }
          }
        for (int i = 0; i < maxn; i++)
          for (int j = 0; j < maxn; j++)
            for (int k = 0; k < maxn; k++) dp[i][j][k] = 0;
        dp[0][0][0] = 1;
        for (int i = 0; i < n; i++)
          for (int j = 0; j <= g2; j++)
            for (int k = 0; k <= s2; k++) {
              if (dp[i][j][k] == 0) continue;
              if (gold[i]) dp[i + 1][j + 1][k] += dp[i][j][k];
              if (silver[i]) dp[i + 1][j][k + 1] += dp[i][j][k];
              if (copper[i]) dp[i + 1][j][k] += dp[i][j][k];
            }
        for (int i = g1; i <= g2; i++)
          for (int j = s1; j <= s2; j++) ans += dp[n][i][j];
      }
  printf("%lld\n", ans);
}
