#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll inf = 0x3FFFFFFFFFFF;
constexpr ll mod = 1000000007;
struct edge {
  ll from, to, w;
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n, m, q;
  cin >> n >> m >> q;
  q++;
  vector<edge> edges;
  vector<ll> ma(n);
  for (ll i = 0; i < m; i++) {
    ll a, b, w;
    cin >> a >> b >> w;
    a--;
    b--;
    edges.push_back({a, b, w});
    edges.push_back({b, a, w});
    ma[a] = max(ma[a], w);
    ma[b] = max(ma[b], w);
  }
  vector<ll> res(n, 0);
  vector<ll> tmp(n, -inf);
  tmp[0] = 0;
  for (ll i = 0; i < n; i++) {
    res[i] = *max_element(begin(tmp), end(tmp)) % mod;
    vector<ll> tmp2(n, -inf);
    for (auto e : edges) {
      tmp2[e.to] = max(tmp2[e.to], tmp[e.from] + e.w);
    }
    swap(tmp, tmp2);
  }
  ll ans = 0;
  for (ll i = 0; i < n; i++) ans += res[i];
  ans %= mod;
  auto eval = [&](ll id, ll x) { return (x - n) * ma[id] + tmp[id]; };
  auto best = [&](ll x) {
    ll res = 0;
    for (ll i = 0; i < n; i++) {
      if (eval(res, x) < eval(i, x)) res = i;
    }
    return res;
  };
  auto sum = [&](ll id, ll x) {
    x -= n;
    ll res = (x * tmp[id]) % mod;
    res += ((x * (x - 1)) / 2 % mod) * ma[id];
    return res % mod;
  };
  ll last = n;
  while (last < q) {
    ll l = last;
    ll r = q;
    ll bestl = best(l);
    while (l + 1 < r) {
      ll m = (l + r) / 2;
      if (best(m) == bestl) {
        l = m;
      } else {
        r = m;
      }
    }
    ans += sum(bestl, r);
    ans %= mod;
    ans -= sum(bestl, last);
    ans %= mod;
    last = r;
  }
  ans += mod;
  ans %= mod;
  cout << ans << endl;
}
