#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
int e[50][50], lo[50], hi[50];
long long dp[50][50];
int main() {
  int n, m, g1, g2, s1, s2;
  scanf("%d%d", &n, &m);
  memset(e, 63, sizeof(e));
  for (int i = 0; i < n; i++) e[i][i] = 0, lo[i] = INF, hi[i] = -INF;
  for (int i = 0; i < m; i++) {
    int x, y, c;
    scanf("%d%d%d", &x, &y, &c);
    --x, --y;
    e[x][y] = e[y][x] = min(e[x][y], c);
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (i != j) {
        e[i][j] = e[i][j] * 100 + i;
        lo[i] = min(lo[i], e[i][j]);
        hi[i] = max(hi[i], e[i][j]);
      }
  scanf("%d%d%d%d", &g1, &g2, &s1, &s2);
  long long ans = 0;
  for (int fast = 0; fast < n; fast++)
    for (int slow = 0; slow < n; slow++) {
      if (fast == slow || lo[fast] >= hi[slow]) continue;
      bool G[50] = {}, S[50] = {}, B[50] = {};
      for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
          if (i != j) {
            if (e[i][j] <= lo[fast])
              G[i] = true;
            else if (e[i][j] >= hi[slow])
              B[i] = true;
            else
              S[i] = true;
          }
      G[fast] = true;
      S[fast] = B[fast] = false;
      B[slow] = true;
      S[slow] = G[slow] = false;
      memset(dp, 0, sizeof(dp));
      dp[0][0] = 1;
      for (int k = 0; k < n; k++)
        for (int i = g2; ~i; i--)
          for (int j = s2; ~j; j--)
            if (dp[i][j]) {
              if (G[k]) dp[i + 1][j] += dp[i][j];
              if (S[k]) dp[i][j + 1] += dp[i][j];
              dp[i][j] = B[k] ? dp[i][j] : 0;
            }
      for (int i = g1; i <= g2; i++)
        for (int j = s1; j <= s2; j++) ans += dp[i][j];
    }
  printf("%I64d\n", ans);
}
