#include using namespace std; #define ii pair #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcountll #define ll long long #define mp make_pair #define f first #define s second #define Time (double)clock()/CLOCKS_PER_SEC #define debug(x) std::cout << #x << ": " << x << '\n'; const int N = 307, MOD = 1000 * 1000 * 1000 + 7; int dp[N][N][N]; int w[N][N]; vector g[N]; signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else #define endl '\n' ios_base::sync_with_stdio(0); cin.tie(0); #endif int n, m, k; cin >> n >> m >> k; for (int i = 0; i < m; ++i) { int u, v, c; cin >> u >> v >> c; w[u][v] = c; g[u].app(v); } auto add = [&](int &a, int b) { a += b; if (a >= MOD) a -= MOD; }; for (int i = 1; i <= 300; ++i) dp[1][i][0] = 1; for (int i = 1; i <= n; ++i) { for (int u = 1; u <= 300; ++u) { for (int sum = 0; sum <= k; ++sum) { int &x = dp[i][u][sum]; x %= MOD; if (x == 0) continue; //cout << i << ' ' << u << ' ' << sum << " : " << dp[i][u][sum] << endl; for (int v : g[u]) { if (sum + w[u][v] <= k) { add(dp[i+1][v][sum+w[u][v]], x); } } } } } int ans = 0; for (int i = 1; i <= 300; ++i) add(ans, dp[n][i][k]); cout << ans << endl; }