/*** author: yuji9511 ***/ #include using namespace std; using ll = long long; using lpair = pair; const ll MOD = 1e9+7; const ll INF = 1e18; #define rep(i,m,n) for(ll i=(m);i<(n);i++) #define rrep(i,m,n) for(ll i=(m);i>=(n);i--) #define printa(x,n) for(ll i=0;i void print(H&& h, T&&... t){cout<(t)...);} ll dp[310][310][310] = {}; void solve(){ ll N,M,K; cin >> N >> M >> K; ll P[310], Q[310], C[310]; ll dist[310][310] = {}; rep(i,0,300){ rep(j,0,300){ if(i == j) dist[i][j] = 0; else dist[i][j] = INF; } } rep(i,0,M){ cin >> P[i] >> Q[i] >> C[i]; P[i]--; Q[i]--; dist[P[i]][Q[i]] = C[i]; } rep(i,0,300){ dp[0][i][0] = 1; } rep(n,0,N-1){ rep(i,0,M){ rep(k,0,K+1){ if(k - C[i] >= 0){ dp[n+1][Q[i]][k] += dp[n][P[i]][k - C[i]]; dp[n+1][Q[i]][k] %= MOD; } } } } ll ans = 0; rep(i,0,300){ ans += dp[N-1][i][K]; ans %= MOD; } print(ans); } int main(){ cin.tie(0); ios::sync_with_stdio(false); solve(); }