#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:16777216")
int g1, g2, s1, s2, n, m;
int a[55][55];
long long f[55][55][55], ans;
int main() {
  cin >> n >> m;
  for (int(i) = 0; (i) < (n); ++(i))
    for (int(j) = 0; (j) < (n); ++(j)) a[i][j] = 1000000000;
  for (int(i) = 0; (i) < (m); ++(i)) {
    int p, q, r;
    cin >> p >> q >> r;
    --p;
    --q;
    a[p][q] = a[q][p] = r;
  }
  cin >> g1 >> g2 >> s1 >> s2;
  for (int(k) = 0; (k) < (n); ++(k))
    for (int(i) = 0; (i) < (n); ++(i))
      for (int(j) = 0; (j) < (n); ++(j))
        if (a[i][j] > a[i][k] + a[k][j]) a[i][j] = a[i][k] + a[k][j];
  for (int last = 0; last < n; ++last) {
    int ldist = 1000000000;
    for (int i = 0; i < n; ++i)
      if (i != last) ldist = min(ldist, a[last][i]);
    for (int first = 0; first < n; ++first) {
      int fdist = -1000000000;
      for (int i = 0; i < n; ++i)
        if (i != first) fdist = max(fdist, a[first][i]);
      if (first == last || fdist < ldist || (fdist == ldist && first < last))
        continue;
      memset(f, 0, sizeof(f));
      f[0][0][0] = 1;
      for (int i = 0; i < n; ++i)
        if (i == last) {
          for (int j = 0; j <= g2; ++j)
            for (int k = 0; k <= s2; ++k) f[i + 1][j + 1][k] += f[i][j][k];
        } else if (i == first) {
          for (int j = 0; j <= g2; ++j)
            for (int k = 0; k <= s2; ++k) f[i + 1][j][k] += f[i][j][k];
        } else
          for (int j = 0; j <= g2; ++j)
            for (int k = 0; k <= s2; ++k)
              if (f[i][j][k] && n - i >= g1 - j + s1 - k) {
                bool g = 0, s = 0, b = 0;
                for (int l = 0; l < n; ++l)
                  if (l != i) {
                    if (a[i][l] < ldist || (a[i][l] == ldist && i < last)) {
                      if (!g) {
                        g = 1;
                        f[i + 1][j + 1][k] += f[i][j][k];
                      }
                    } else if (a[i][l] < fdist ||
                               (a[i][l] == fdist && i < first)) {
                      if (!s) {
                        s = 1;
                        f[i + 1][j][k + 1] += f[i][j][k];
                      }
                    } else if (!b) {
                      b = 1;
                      f[i + 1][j][k] += f[i][j][k];
                    }
                  }
              }
      for (int g = g1; g <= g2; ++g)
        for (int s = s1; s <= s2; ++s) ans += f[n][g][s];
    }
  }
  cout << ans << endl;
}
