#include <bits/stdc++.h>
using namespace std;
long long int road[60][60];
vector<long long int> dis[60];
long long int n, m, mini, maxi;
long long int dp[60][60][60];
long long int recur(long long int pos, long long int lower,
                    long long int upper) {
  if (lower < 0 || upper < 0) return 0;
  long long int &res = dp[pos][lower][upper];
  if (res != -1) return res;
  res = 0;
  if (pos == n) return res = (lower == 0 && upper == 0);
  if (dis[pos].front() == mini) return res = recur(pos + 1, lower - 1, upper);
  if (dis[pos].back() == maxi) return res = recur(pos + 1, lower, upper);
  if (dis[pos].front() < mini) res += recur(pos + 1, lower - 1, upper);
  if (maxi < dis[pos].back()) res += recur(pos + 1, lower, upper);
  bool ok = false;
  for (long long int i = 0;
       i < ((long long int)(((long long int)dis[pos].size()))); i++)
    if (mini < dis[pos][i] && dis[pos][i] < maxi) ok = true;
  if (ok) res += recur(pos + 1, lower, upper - 1);
  return res;
}
int main() {
  for (long long int i = 0; i < ((long long int)(60)); i++)
    for (long long int j = 0; j < ((long long int)(60)); j++)
      road[i][j] = (1ll << (long long int)(25));
  cin >> n >> m;
  for (long long int i = 0; i < ((long long int)(m)); i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    road[a - 1][b - 1] = min(road[a - 1][b - 1], c);
    road[b - 1][a - 1] = min(road[b - 1][a - 1], c);
  }
  for (long long int k = 0; k < ((long long int)(n)); k++)
    for (long long int i = 0; i < ((long long int)(n)); i++)
      for (long long int j = 0; j < ((long long int)(n)); j++)
        road[i][j] = min(road[i][j], road[i][k] + road[k][j]);
  for (long long int i = 0; i < ((long long int)(n)); i++)
    for (long long int j = 0; j < ((long long int)(n)); j++)
      if (i != j) dis[i].push_back(road[i][j] * 60 + i);
  for (long long int i = 0; i < ((long long int)(n)); i++)
    sort(dis[i].begin(), dis[i].end());
  long long int sx, sy, gx, gy, res = 0;
  cin >> sx >> sy >> gx >> gy;
  for (long long int i = 0; i < ((long long int)(n)); i++)
    for (long long int j = 0; j < ((long long int)(n)); j++)
      if (i != j) {
        memset(dp, -1, sizeof(dp));
        mini = dis[i].front();
        maxi = dis[j].back();
        for (long long int s = sx; s <= sy; s++)
          for (long long int g = gx; g <= gy; g++) res += recur(0, s, g);
      }
  cout << res << endl;
}
