#include <bits/stdc++.h>
using namespace std;
long long f[55][55][55];
int d[55][55];
int n, m;
int g1, g2, s1, s2;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) d[i][j] = (i == j ? 0 : 1000000);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d%d%d", &u, &v, &w);
    --u, --v;
    d[u][v] = min(d[u][v], w);
    d[v][u] = d[u][v];
  }
  for (int k = 0; k < n; k++)
    for (int i = 0; i < n; i++)
      for (int j = 0; j < n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  scanf("%d%d%d%d", &g1, &g2, &s1, &s2);
  for (int i = 0; i < n; i++) {
    sort(d[i], d[i] + n);
  }
  long long ans = 0;
  for (int p = 0; p < n; p++)
    for (int q = 0; q < n; q++)
      if (p != q) {
        if (d[p][1] > d[q][n - 1] || (d[p][1] == d[q][n - 1] && p > q))
          continue;
        memset(f, 0, sizeof(f));
        f[0][0][0] = 1;
        for (int i = 0; i < n; i++) {
          int g = 0, s = 0, b = 0;
          if (i == p)
            g = 1;
          else if (i == q)
            b = 1;
          else {
            if (d[i][1] < d[p][1] || (d[i][1] == d[p][1] && i < p)) g = 1;
            if (d[i][n - 1] > d[q][n - 1] ||
                (d[i][n - 1] == d[q][n - 1] && i > q))
              b = 1;
            int l, r, v;
            if (i < p)
              v = d[p][1] + 1;
            else
              v = d[p][1];
            l = lower_bound(d[i] + 1, d[i] + n, v) - d[i];
            if (i > q)
              v = d[q][n - 1] - 1;
            else
              v = d[q][n - 1];
            r = upper_bound(d[i] + 1, d[i] + n, v) - d[i];
            if (l < r) s = 1;
          }
          for (int j = 0; j <= i; j++)
            for (int k = 0; j + k <= i; k++) {
              if (g) f[i + 1][j + 1][k] += f[i][j][k];
              if (s) f[i + 1][j][k + 1] += f[i][j][k];
              if (b) f[i + 1][j][k] += f[i][j][k];
            }
        }
        for (int g = g1; g <= g2; g++)
          for (int s = s1; s <= s2; s++)
            if (g + s < n) ans += f[n][g][s];
      }
  printf("%I64d\n", ans);
  return 0;
}
