#include <bits/stdc++.h>
using namespace std;
const int maxn = 2020, mod = 1000000007;
inline void Add(int &a, int b) { a = a + b >= mod ? a + b - mod : a + b; }
int head[maxn], nxt[maxn << 1], ver[maxn << 1], val[maxn << 1], tot;
inline void addedge(int a, int b, int c) {
  nxt[++tot] = head[a];
  ver[tot] = b;
  val[tot] = c;
  head[a] = tot;
  nxt[++tot] = head[b];
  ver[tot] = a;
  val[tot] = c;
  head[b] = tot;
}
long long f[maxn], g[maxn];
int n, m, q, ans = 0, top, mxv[maxn], stk[maxn];
struct Line {
  long long k, b;
} L[maxn];
inline int cal(const Line &L, int x) { return (1ll * L.k * x + L.b) % mod; }
inline int cmp(const Line &a, const Line &b) {
  return a.k < b.k || (a.k == b.k && a.b < b.b);
}
struct Frac {
  long long a, b, c;
  Frac() {}
  Frac(long long x, long long y) {
    a = x / y;
    c = y;
    b = x % y;
  }
  inline long long floor() { return a; }
  inline long long ceil() { return a + (b != 0); }
  bool operator<(const Frac &x) {
    if (a != x.a) return a < x.a;
    return b * x.c < x.b * c;
  }
};
inline Frac get(int x, int y) { return Frac(L[x].b - L[y].b, L[y].k - L[x].k); }
int main() {
  scanf("%d%d%d", &n, &m, &q);
  for (int i = 1, a, b, c; i <= m; i++)
    scanf("%d%d%d", &a, &b, &c), addedge(a, b, c), mxv[a] = max(mxv[a], c),
                                                   mxv[b] = max(mxv[b], c);
  for (int i = 1; i <= n; i++) f[i] = -1e18;
  f[1] = 0;
  for (int i = 1; i <= min(m, q); i++) {
    long long ttt = -1e18;
    for (int j = 1; j <= n; j++) g[j] = -1e18;
    for (int j = 1; j <= n; j++)
      for (int k = head[j]; k; k = nxt[k])
        g[ver[k]] = max(g[ver[k]], f[j] + val[k]);
    for (int j = 1; j <= n; j++) ttt = max(ttt, f[j] = g[j]);
    Add(ans, ttt % mod);
  }
  if (q <= m) return printf("%d\n", ans), 0;
  q -= m;
  for (int i = 1; i <= n; i++) L[i] = (Line){mxv[i], f[i]};
  sort(L + 1, L + n + 1, cmp);
  for (int i = 1; i <= n; i++) {
    if (i < n && L[i + 1].k == L[i].k) continue;
    while (top && get(stk[top], i) < get(stk[top - 1], stk[top])) top--;
    stk[++top] = i;
  }
  int now = 1;
  for (int i = 1; i <= top; i++) {
    bool flag = 0;
    long long l = now, r = (i == top) ? q : get(stk[i], stk[i + 1]).floor();
    if (l > r) continue;
    if (r >= q) flag = 1, r = q;
    Add(ans, 1ll * (cal(L[stk[i]], l) + cal(L[stk[i]], r)) % mod * (r - l + 1) %
                 mod * 500000004 % mod);
    if (flag) break;
    now = r + 1;
  }
  printf("%d\n", ans);
}
