#include #include using namespace std; using ll = long long; const ll mod = 1000000009; ll dp[301][301][301]; struct edge { int to; ll cost; edge(int to, ll cost):to(to), cost(cost) {} }; int main() { int n, m, k; cin >> n >> m >> k; vector> G(300); for (int i = 0; i < m; ++i) { int p, q; ll c; cin >> p >> q >> c; p--; q--; G[p].push_back(edge(q, c)); } for (int i = 0; i < 300; ++i) dp[0][i][0] = 1; for (int i = 0; i < n - 1; ++i) { for (int s = 0; s < 300; ++s) { for (int j = 0; j < k + 1; ++j) { for (edge& e : G[s]) { if (j + e.cost <= k) { dp[i + 1][e.to][j + e.cost] += dp[i][s][j]; dp[i + 1][e.to][j + e.cost] %= mod; } } } } } ll ans = 0; for (int i = 0; i < 300; ++i) { ans += dp[n - 1][i][k]; ans %= mod; } cout << ans << endl; return 0; }