#include <bits/stdc++.h>
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int main() {
  static int dd[50][50], dmin[50], dmax[50];
  static long long dp[50 + 1][50 + 1];
  int n, m, h, i, j, k, l, g1, g2, s1, s2, g, s;
  long long ans;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) memset(dd[i], 0x3f, n * sizeof *dd[i]), dd[i][i] = 0;
  for (h = 0; h < m; h++) {
    int w;
    scanf("%d%d%d", &i, &j, &w), i--, j--;
    dd[i][j] = dd[j][i] = w;
  }
  scanf("%d%d%d%d", &g1, &g2, &s1, &s2);
  for (k = 0; k < n; k++)
    for (i = 0; i < n; i++)
      for (j = 0; j < n; j++) dd[i][j] = min(dd[i][j], dd[i][k] + dd[k][j]);
  for (i = 0; i < n; i++) {
    dmin[i] = 0x3f3f3f3f, dmax[i] = 0;
    for (j = 0; j < n; j++)
      if (j != i)
        dmin[i] = min(dmin[i], dd[i][j]), dmax[i] = max(dmax[i], dd[i][j]);
  }
  ans = 0;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (i != j && dmin[i] < dmax[j] || dmin[i] == dmax[j] && i < j) {
        for (g = 0; g <= n; g++) memset(dp[g], 0, (n + 1) * sizeof *dp[g]);
        dp[1][0] = 1;
        for (k = 0; k < n; k++)
          if (k != i && k != j) {
            int di = dmin[i], dj = dmax[j], cang, cans, canb;
            cang = dmin[k] < di || dmin[k] == di && k < i;
            canb = dmax[k] > dj || dmax[k] == dj && k > j;
            cans = 0;
            for (l = 0; l < n; l++)
              if (l != k && (di < dd[k][l] || di == dd[k][l] && i < k) &&
                  (dd[k][l] < dj || dd[k][l] == dj && k < j)) {
                cans = 1;
                break;
              }
            for (g = n; g >= 0; g--)
              for (s = n; s >= 0; s--) {
                long long x = dp[g][s];
                if (x == 0) continue;
                if (!canb) dp[g][s] = 0;
                if (cang) dp[g + 1][s] += x;
                if (cans) dp[g][s + 1] += x;
              }
          }
        for (g = g1; g <= g2; g++)
          for (s = s1; s <= s2; s++) ans += dp[g][s];
      }
  printf("%lld\n", ans);
  return 0;
}
