#include <bits/stdc++.h>
using namespace std;
const int MAXN = 64 + 1;
const int INF = 1012345678;
int n, m, g1, g2, s1, s2, mat[MAXN][MAXN], best[MAXN], worst[MAXN];
long long dp[2][MAXN][MAXN];
inline long long calc(int x, int y) {
  dp[0][0][0] = 1;
  int t1 = 0, t2;
  for (int o = 1; o <= n; o++) {
    t2 = t1 ^ 1;
    for (int i = o; i >= 0; i--) {
      for (int j = o - i; j >= 0; j--) {
        dp[t2][i][j] = 0;
      }
    }
    bool g = false, s = false, b = false;
    if (o - 1 == x) {
      g = true;
    } else if (o - 1 == y) {
      b = true;
    } else {
      if (best[o - 1] < best[x]) {
        g = true;
      }
      if (worst[o - 1] > worst[y]) {
        b = true;
      }
      for (int i = 0; i < n; i++) {
        if (o - 1 == i) continue;
        if (best[x] < ((mat[o - 1][i] << 6) | (o - 1)) &&
            ((mat[o - 1][i] << 6) | (o - 1)) < worst[y]) {
          s = true;
          break;
        }
      }
    }
    for (int i = o - 1; i >= 0; i--) {
      for (int j = o - 1 - i; j >= 0; j--) {
        if (g) {
          dp[t2][i + 1][j] += dp[t1][i][j];
        }
        if (s) {
          dp[t2][i][j + 1] += dp[t1][i][j];
        }
        if (b) {
          dp[t2][i][j] += dp[t1][i][j];
        }
      }
    }
    t1 = t2;
  }
  long long res = 0;
  for (int i = g1; i <= g2; i++) {
    for (int j = s1; j <= s2; j++) {
      res += dp[t1][i][j];
    }
  }
  return res;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      mat[i][j] = INF;
    }
    mat[i][i] = 0;
  }
  for (int i = 0; i < m; i++) {
    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);
    x--;
    y--;
    mat[x][y] = mat[y][x] = min(mat[x][y], z);
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        mat[i][j] = min(mat[i][j], mat[i][k] + mat[k][j]);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    best[i] = worst[i] = i ? mat[i][0] : mat[i][1];
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      best[i] = min(best[i], mat[i][j]);
      worst[i] = max(worst[i], mat[i][j]);
    }
    best[i] = (best[i] << 6) | i;
    worst[i] = (worst[i] << 6) | i;
  }
  scanf("%d%d%d%d", &g1, &g2, &s1, &s2);
  long long res = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      res += calc(i, j);
    }
  }
  printf("%lld\n", res);
  return 0;
}
