#include <bits/stdc++.h>
using namespace std;
int n, m;
int dis[52][52];
int mind[52], maxd[52];
bool g[52], s[52], b[52];
long long f[52][52], v;
int main() {
  scanf("%d%d", &n, &m);
  int g1, g2, s1, s2;
  memset(dis, 3, sizeof dis);
  for (int i = 1, u, v, c; i <= m; i++) {
    scanf("%d%d%d", &u, &v, &c);
    dis[u][v] = dis[v][u] = c;
  }
  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 (i != j && j != k && k != i && dis[i][j] > dis[i][k] + dis[k][j])
          dis[i][j] = dis[j][i] = dis[i][k] + dis[k][j];
  memset(mind, 3, sizeof mind);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j)
        mind[i] = min(mind[i], dis[i][j] * 100 + i),
        maxd[i] = max(maxd[i], dis[i][j] * 100 + i);
  long long Res = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (i != j && mind[i] < maxd[j]) {
        memset(g, false, sizeof g);
        memset(s, false, sizeof s);
        memset(b, false, sizeof b);
        for (int k = 1; k <= n; k++) {
          g[k] = mind[k] < mind[i];
          b[k] = maxd[k] > maxd[j];
          for (int l = 1; l <= n && !s[k]; l++)
            s[k] = (l != k && dis[k][l] * 100 + k > mind[i] &&
                    dis[k][l] * 100 + k < maxd[j]);
        }
        g[i] = true, s[i] = b[i] = false;
        b[j] = true, g[j] = s[j] = false;
        memset(f, 0, sizeof f);
        f[0][0] = 1;
        for (int k = 1; k <= n; k++)
          for (int p = g2; p >= 0; p--)
            for (int q = s2; q >= 0; q--)
              if (v = f[p][q]) {
                if (g[k]) f[p + 1][q] += v;
                if (s[k]) f[p][q + 1] += v;
                if (!b[k]) f[p][q] = 0;
              }
        for (int p = g1; p <= g2; p++)
          for (int q = s1; q <= s2; q++) Res = Res + f[p][q];
      }
  printf("%I64d\n", Res);
  return 0;
}
