#include <bits/stdc++.h>
template <typename T>
void read(T& x) {
  x = 0;
  int flag = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') flag = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= flag;
}
using namespace std;
const int maxn = 55, inf = 0x3f3f3f3f;
int n, m, mp[maxn][maxn], mx[maxn], mn[maxn], g1, g2, s1, s2;
bool g[maxn], s[maxn], b[maxn];
long long ans, dp[maxn][maxn][maxn];
int main() {
  scanf("%d %d", &n, &m);
  memset(mp, 0x3f, sizeof(mp));
  memset(mn, 0x3f, sizeof(mn));
  memset(mx, -0x3f, sizeof(mx));
  for (int i = 1; i <= (int)m; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    mp[u][v] = mp[v][u] = w;
  }
  for (int k = 1; k <= (int)n; k++)
    for (int i = 1; i <= (int)n; i++)
      for (int j = 1; j <= (int)n; j++)
        mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
  for (int i = 1; i <= (int)n; i++)
    for (int j = 1; j <= (int)n; j++)
      if (mp[i][j] != inf) mp[i][j] = mp[i][j] * 100 + i;
  scanf("%d %d %d %d", &g1, &g2, &s1, &s2);
  for (int i = 1; i <= (int)n; i++)
    for (int j = 1; j <= (int)n; j++)
      if (i != j) mn[i] = min(mn[i], mp[i][j]), mx[i] = max(mx[i], mp[i][j]);
  for (int best = 1; best <= (int)n; best++)
    for (int worst = 1; worst <= (int)n; worst++)
      if (best != worst && mn[best] < mx[worst]) {
        for (int i = 1; i <= (int)n; i++) {
          g[i] = mn[i] <= mn[best], b[i] = mx[i] >= mx[worst], s[i] = 0;
          for (int j = 1; j <= (int)n; j++)
            if (i != j && mp[i][j] > mn[best] && mp[i][j] < mx[worst]) s[i] = 1;
        }
        s[best] = b[best] = g[worst] = s[worst] = 0;
        memset(dp, 0, sizeof(dp));
        dp[0][0][0] = 1;
        for (int i = 1; i <= (int)n; i++)
          for (int j = 0; j <= (int)i; j++)
            for (int k = 0; k <= (int)i - j; k++) {
              if (j && g[i]) dp[i][j][k] += dp[i - 1][j - 1][k];
              if (k && s[i]) dp[i][j][k] += dp[i - 1][j][k - 1];
              if (b[i]) dp[i][j][k] += dp[i - 1][j][k];
            }
        for (int i = g1; i <= (int)g2; i++)
          for (int j = s1; j <= (int)s2; j++) ans += dp[n][i][j];
      }
  printf("%lld\n", ans);
  return 0;
}
