#include <bits/stdc++.h>
using namespace std;
int n, m, g1, g2, s1, s2, dist[55][55], mn[55], mx[55], cgg[55], cgs[55],
    cgb[55];
long long dp[55][55][55], ans = 0;
long long ddpp(int xh, int cntg, int cnts) {
  if (xh == n) {
    return g1 <= cntg && cntg <= g2 && s1 <= cnts && cnts <= s2;
  }
  if (dp[xh][cntg][cnts] != -1) {
    return dp[xh][cntg][cnts];
  }
  dp[xh][cntg][cnts] = 0;
  if (cgg[xh]) {
    dp[xh][cntg][cnts] += ddpp(xh + 1, cntg + 1, cnts);
  }
  if (cgs[xh]) {
    dp[xh][cntg][cnts] += ddpp(xh + 1, cntg, cnts + 1);
  }
  if (cgb[xh]) {
    dp[xh][cntg][cnts] += ddpp(xh + 1, cntg, cnts);
  }
  return dp[xh][cntg][cnts];
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dist[i][j] = 1e9 + 1000;
    }
  }
  for (int i = 0; i < n; i++) {
    dist[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    dist[a][b] = c;
    dist[b][a] = c;
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }
  cin >> g1 >> g2 >> s1 >> s2;
  for (int i = 0; i < n; i++) {
    mn[i] = 1e9 + 1000;
    mx[i] = 0;
    for (int j = 0; j < n; j++) {
      if (i == j) {
        continue;
      }
      mn[i] = min(mn[i], dist[i][j]);
      mx[i] = max(mx[i], dist[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        continue;
      }
      memset(dp, -1, sizeof(dp));
      memset(cgg, 0, sizeof(cgg));
      memset(cgs, 0, sizeof(cgs));
      memset(cgb, 0, sizeof(cgb));
      for (int k = 0; k < n; k++) {
        if (k == i) {
          cgg[k] = 1;
          continue;
        }
        if (k == j) {
          cgb[k] = 1;
          continue;
        }
        for (int l = 0; l < n; l++) {
          if (k == l) {
            continue;
          }
          if (make_pair(dist[k][l], k) < make_pair(mn[i], i)) {
            cgg[k] = 1;
          } else if (make_pair(dist[k][l], k) > make_pair(mx[j], j)) {
            cgb[k] = 1;
          } else {
            cgs[k] = 1;
          }
        }
      }
      ans += ddpp(0, 0, 0);
    }
  }
  cout << ans << endl;
  return 0;
}
