#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int d[60][60], mx[60], mi[60], n, m, g1, g2, s1, s2, in[60];
long long f[60][60][60], ans = 0;
int main() {
  scanf("%d%d", &n, &m);
  memset(d, 63, sizeof(d));
  int x, y, z;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &x, &y, &z);
    d[x][y] = d[y][x] = min(d[x][y], z);
  }
  scanf("%d%d%d%d", &g1, &g2, &s1, &s2);
  for (int k = 1; k <= n; k++)
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= n; j++)
        if (k != i && i != j && j != k)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  for (int i = 1; i <= n; i++) {
    mx[i] = 0;
    mi[i] = inf;
    for (int j = 1; j <= n; j++) {
      if (d[i][j] < inf) {
        d[i][j] = d[i][j] * n + i;
        mi[i] = min(mi[i], d[i][j]);
        mx[i] = max(mx[i], d[i][j]);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i == j) continue;
      int au = mi[i], cu = mx[j];
      if (au > cu) continue;
      for (int k = 1; k <= n; k++) {
        in[k] = 0;
        for (int p = 1; p <= n; p++) {
          if (k == p) continue;
          if (d[k][p] > au && d[k][p] < cu) in[k] = 1;
        }
      }
      memset(f, 0, sizeof(f));
      f[0][1][0] = 1;
      for (int k = 1; k <= n; k++) {
        if (k == i || k == j) {
          memcpy(f[k], f[k - 1], sizeof(f[k]));
          continue;
        }
        for (int g = 1; g <= k; g++) {
          for (int s = 0; s + g <= k; s++) {
            if (f[k - 1][g][s]) {
              if (mi[k] <= au) f[k][g + 1][s] += f[k - 1][g][s];
              if (in[k]) f[k][g][s + 1] += f[k - 1][g][s];
              if (mx[k] >= cu) f[k][g][s] += f[k - 1][g][s];
            }
          }
        }
      }
      for (int g = g1; g <= g2; g++)
        for (int s = s1; s <= s2; s++) ans += f[n][g][s];
    }
  }
  cout << ans << endl;
  return 0;
}
