#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef long double ld; typedef pair P; constexpr int mod = 1e9 + 7; constexpr int CMAX = 300; int main() { int n, m, k; cin >> n >> m >> k; vector> g(300); rep(i,m) { int p, q, c; cin >> p >> q >> c; p--; q--; g[p].emplace_back(make_pair(q, c)); } vector> dp(300, vector(CMAX + 1, 0)); for (int u = 0; u < 300; u++) { for (auto p : g[u]) { int v = p.first; int cost = p.second; dp[v][cost]++; } } for (int i = 0; i < n - 2; i++) { vector> ndp(300, vector(CMAX + 1, 0)); for (int u = 0; u < 300; u++) { for (auto p : g[u]) { int v = p.first; int cost = p.second; for (int j = 0; j <= CMAX; j++) { if (j + cost <= CMAX) (ndp[v][j + cost] += dp[u][j]) %= mod; } } } swap(dp, ndp); } int res = 0; for (int i = 0; i < 300; i++) (res += dp[i][k]) %= mod; cout << res << endl; return 0; }