#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 60, INF = 1e9;
long long dp[MAXN][MAXN][MAXN];
long long dis[MAXN][MAXN];
bool cmp(long long a, long long b, long long v1, long long v2) {
  if (v1 < v2) return true;
  if (v1 == v2) return a < b;
  return false;
}
int32_t main() {
  long long n, m, ans = 0;
  cin >> n >> m;
  for (long long i = 0; i < n; ++i)
    for (long long j = i + 1; j < n; ++j) dis[i][j] = dis[j][i] = INF;
  while (m--) {
    long long a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    --a1;
    --a2;
    dis[a1][a2] = dis[a2][a1] = min(dis[a1][a2], a3);
  }
  long long g1, g2, s1, s2;
  cin >> g1 >> g2 >> s1 >> s2;
  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] = dis[j][i] = min(dis[i][j], dis[i][k] + dis[k][j]);
  for (long long i = 0; i < n; ++i) sort(dis[i], dis[i] + n);
  for (long long i = 0; i < n; ++i)
    for (long long j = 0; j < n; ++j)
      if (i != j) {
        memset(dp, 0, sizeof(dp));
        dp[0][0][0] = 1;
        for (long long now = 1; now <= n; ++now) {
          bool b[3] = {};
          if (cmp(now - 1, i, dis[now - 1][1], dis[i][1])) b[0] = true;
          for (long long t = 1; t < n; ++t)
            if (!cmp(now - 1, i, dis[now - 1][t], dis[i][1]) &&
                cmp(now - 1, j, dis[now - 1][t], dis[j][n - 1]))
              b[1] = true;
          if (!cmp(now - 1, j, dis[now - 1][n - 1], dis[j][n - 1])) b[2] = true;
          if (now == i + 1) {
            b[0] = true;
            b[1] = false;
            b[2] = false;
          }
          if (now == j + 1) {
            b[0] = false;
            b[1] = false;
            b[2] = true;
          }
          for (long long g = 0; g <= n; ++g)
            for (long long s = 0; s + g <= n; ++s) {
              if (b[0]) dp[now][g + 1][s] += dp[now - 1][g][s];
              if (b[1]) dp[now][g][s + 1] += dp[now - 1][g][s];
              if (b[2]) dp[now][g][s] += dp[now - 1][g][s];
            }
        }
        for (long long g = g1; g <= g2; ++g)
          for (long long s = s1; s <= s2; ++s) ans += dp[n][g][s];
      }
  cout << ans;
  return 0;
}
