#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while ((c < '0' || c > '9') && (c != '-')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
const int N = 2010, mod = 1e9 + 7;
const long long inf = 1ll << 60;
int n, m, q, x[N], y[N], z[N], top;
long long f[N][N];
struct line {
  long long k, b;
} a[N], stk[N];
inline pair<double, double> cross(line a, line b) {
  double x = 1.0 * (a.b - b.b) / (b.k - a.k);
  return make_pair(x, a.k * x + a.b);
}
inline bool check(line a, line b, line c) {
  auto o = cross(a, c);
  return o.second >= o.first * b.k + b.b;
}
inline int calc(int l, int r) { return 1ll * (l + r) * (r - l + 1) / 2 % mod; }
inline int calc(long long l, long long r, line x) {
  if (l > r) return 0;
  return (1ll * (r - l + 1) * (x.b % mod) + 1ll * x.k * calc(l, r)) % mod;
}
int main() {
  n = read(), m = read(), q = read();
  for (register int i = (1); i <= (m); i++)
    x[i] = read(), y[i] = read(), z[i] = read();
  for (register int i = (0); i <= (n); i++)
    for (register int j = (1); j <= (n); j++) f[i][j] = -inf;
  f[0][1] = 0;
  int ans = 0;
  for (register int j = (1); j <= (m); j++) {
    for (register int i = (1); i <= (m); i++) {
      f[j][x[i]] = max(f[j][x[i]], f[j - 1][y[i]] + z[i]);
      f[j][y[i]] = max(f[j][y[i]], f[j - 1][x[i]] + z[i]);
    }
    long long mx = -inf;
    for (register int i = (1); i <= (n); i++) mx = max(mx, f[j][i]);
    ans = (ans + mx) % mod;
  }
  for (register int i = (1); i <= (m); i++)
    a[i] = (line){z[i], max(f[m][x[i]], f[m][y[i]]) - 1ll * z[i] * m};
  sort(a + 1, a + 1 + m,
       [](line a, line b) { return a.k < b.k || (a.k == b.k && a.b > b.b); });
  for (register int i = (1); i <= (m); i++) {
    if (a[i].k == a[i - 1].k) continue;
    while (top > 1 && check(stk[top - 1], stk[top], a[i])) --top;
    stk[++top] = a[i];
  }
  if (top == 1)
    ans = (ans + calc(m + 1, q, stk[1])) % mod;
  else {
    long long r = cross(stk[1], stk[2]).first;
    r = min(r, (long long)q);
    ans = (ans + calc(m + 1, r, stk[1])) % mod;
    for (register int i = (2); i < (top); i++) {
      long long l = cross(stk[i - 1], stk[i]).first + 1;
      long long r = cross(stk[i], stk[i + 1]).first;
      l = max(l, (long long)m + 1), r = min(r, (long long)q);
      ans = (ans + calc(l, r, stk[i])) % mod;
    }
    long long l = cross(stk[top - 1], stk[top]).first + 1;
    l = max(l, (long long)m + 1);
    ans = (ans + calc(l, q, stk[top])) % mod;
  }
  printf("%d\n", (ans + mod) % mod);
}
