#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long fast(long long x, long long n) {
  long long ans = 1;
  for (; n; n >>= 1, x = x * x % mod)
    if (n & 1) ans = ans * x % mod;
  return ans;
}
const int N = 2000 + 100;
const long long inf = 0x3f3f3f3f3f3f;
struct Edge {
  long long to, nex, val;
} edge[N * 2];
int head[N], pos;
void add(long long a, long long b, long long c) {
  edge[++pos] = {b, head[a], c};
  head[a] = pos;
}
long long dp[N][N], n, m, q, m1[N], u[N], v[N], w[N];
int main() {
  cin >> n >> m >> q;
  for (long long i = 1, a, b, c; i <= m; i++)
    scanf("%lld%lld%lld", &a, &b, &c), add(a, b, c), add(b, a, c),
        u[i] = a, v[i] = b, w[i] = c;
  memset(dp, -0x3f, sizeof dp);
  dp[1][0] = 0;
  long long ans = 0;
  for (int i = 1; i <= m; i++) {
    long long maxx = -inf;
    for (int j = 1; j <= n; j++)
      for (int k = head[j]; k; k = edge[k].nex) {
        int to = edge[k].to, val = edge[k].val;
        dp[to][i] = max(dp[to][i], dp[j][i - 1] + val);
        maxx = max(maxx, dp[to][i]);
      }
    ans = (ans + maxx) % mod;
  }
  for (int i = 1; i <= m; i++) m1[i] = max(dp[u[i]][m], dp[v[i]][m]);
  long long inv2 = fast(2, mod - 2), r;
  for (long long l = m + 1; l <= q; l = r + 1) {
    r = q;
    long long pos = -1, maxx = -inf;
    for (int i = 1; i <= m; i++) {
      long long temp = m1[i] + (l - m) * w[i];
      if (temp > maxx) maxx = temp, pos = i;
    }
    for (int i = 1; i <= m; i++)
      if (w[i] > w[pos]) {
        r = min(r, (m1[pos] - m1[i]) / (w[i] - w[pos]) + m);
      }
    (ans +=
     (m1[pos] + (l - m) * w[pos] % mod + m1[pos] + (r - m) * w[pos] % mod) %
     mod * (r - l + 1) % mod * inv2 % mod) %= mod;
  }
  cout << ans;
}
