#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 50 + 3;
long long n, m, dis[MAXN][MAXN], g[2], s[2], dp[MAXN][MAXN][MAXN], ans;
vector<pair<long long, long long> > f[MAXN];
bitset<MAXN> can[3];
long long cal() {
  long long ret = 0;
  memset(dp, 0, sizeof dp);
  dp[0][0][0] = 1;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j <= n; j++)
      for (long long k = 0; k <= n; k++) {
        if (can[0][i]) dp[i + 1][j][k] += dp[i][j][k];
        if (can[1][i] && j > 0) dp[i + 1][j][k] += dp[i][j - 1][k];
        if (can[2][i] && k > 0) dp[i + 1][j][k] += dp[i][j][k - 1];
      }
  for (long long i = s[0]; i <= s[1]; i++)
    for (long long j = g[0]; j <= g[1]; j++) ret += dp[n][i][j];
  return ret;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  memset(dis, 63, sizeof dis);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long u, v, c;
    cin >> u >> v >> c;
    dis[--u][--v] = c;
    dis[v][u] = c;
  }
  cin >> g[0] >> g[1] >> s[0] >> s[1];
  for (long long k = 0; k < n; k++)
    for (long long i = 0; i < n; i++)
      for (long long j = 0; j < n; j++)
        dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++)
      if (i != j) f[i].push_back({dis[i][j], i});
  for (long long i = 0; i < n; i++)
    sort(f[i].begin(), f[i].end(), greater<pair<long long, long long> >());
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < n; j++)
      if (i != j) {
        can[0].reset(), can[1].reset(), can[2].reset();
        can[0][i] = can[2][j] = true;
        for (long long k = 0; k < n; k++)
          if (k != i && k != j)
            for (auto q : f[k]) {
              if (q > f[i][0]) can[0][k] = true;
              if (q < f[i][0] && q > f[j].back()) can[1][k] = true;
              if (q < f[j].back()) can[2][k] = true;
            }
        ans += cal();
      }
  cout << ans;
  return 0;
}
