#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  char c = getchar();
  long long su = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) su = su * 10 + c - '0';
  return su * f;
}
inline void wr(long long x) {
  if (x < 0) {
    putchar('-');
    wr(-x);
    return;
  }
  if (x >= 10) wr(x / 10);
  putchar(x % 10 + '0');
}
inline void wri(long long x) {
  wr(x);
  putchar(' ');
}
inline void wrn(long long x) {
  wr(x);
  putchar('\n');
}
inline void wrn(long long x, long long y) {
  wri(x);
  wrn(y);
}
inline void wrn(long long x, long long y, long long z) {
  wri(x);
  wrn(y, z);
}
inline void cmx(long long &x, long long y) { x = (x > y) ? x : y; }
long long n, m, zh[2005], tot, q1, g[2005], r[2005];
struct xx {
  long long x, y, w;
} z[2005];
struct po {
  long long x, y;
} q[2005];
bool cmp(po a, po b) { return (a.x == b.x) ? a.y > b.y : a.x < b.x; }
long long ans, dp[2005][2005], mx[2005];
po operator+(po a, po b) { return (po){a.x + b.x, a.y + b.y}; }
po operator-(po a, po b) { return (po){a.x - b.x, a.y - b.y}; }
long long operator*(po a, po b) { return a.x * b.y - a.y * b.x; }
void solve(long long l, long long r, long long k) {
  ans += 1ll * (l + r) * (r - l + 1) / 2 % 1000000007 * q[k].x % 1000000007 +
         1ll * (r - l + 1) * q[k].y % 1000000007;
}
signed main() {
  n = read();
  m = read();
  q1 = read();
  for (long long i = (1); i <= (m); i++)
    z[i].x = read(), z[i].y = read(), z[i].w = read(), cmx(g[z[i].x], z[i].w),
    cmx(g[z[i].y], z[i].w);
  for (long long i = (1); i <= (n); i++)
    for (long long j = (0); j <= (n); j++) dp[i][j] = -20000000000005;
  dp[1][0] = 0;
  for (long long i = (1); i <= (n); i++) {
    for (long long j = (1); j <= (m); j++) {
      long long x = z[j].x, y = z[j].y, w = z[j].w;
      cmx(dp[x][i], dp[y][i - 1] + w);
      cmx(dp[y][i], dp[x][i - 1] + w);
    }
  }
  for (long long i = (1); i <= (n); i++) {
    long long p = -20000000000005;
    for (long long j = (1); j <= (n); j++) {
      cmx(mx[j], dp[i][j]);
      cmx(p, dp[i][j] - j * g[i]);
    }
    q[i] = (po){g[i], p};
  }
  sort(q + 1, q + n + 1, cmp);
  q[0].x = -1;
  for (long long i = (1); i <= (n); i++) {
    if (q[i].x == q[i - 1].x) continue;
    while (tot >= 2 &&
           (q[i] - q[zh[tot - 1]]) * (q[zh[tot]] - q[zh[tot - 1]]) <= 0)
      tot--;
    zh[++tot] = i;
  }
  r[0] = n;
  for (long long i = (1); i < (tot); i++) {
    po t1 = q[zh[i]], t2 = q[zh[i + 1]];
    r[i] = (t1.y - t2.y) / (t2.x - t1.x);
  }
  r[tot] = q1;
  long long l = n + 1;
  for (long long i = (1); i <= (tot); i++) {
    if (l > q1) break;
    if (l > r[i]) continue;
    solve(l, min(q1, r[i]), zh[i]);
    l = r[i] + 1;
  }
  for (long long i = (1); i <= (min(n, q1)); i++) ans += mx[i];
  wrn(ans % 1000000007);
  return 0;
}
