#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; const ll MOD=1e9+7; int main(){ ll n,m,K; cin>>n>>m>>K; ll dp[n+1][301][K+1]; rep(i,n+1){ rep(j,301){ rep(k,K+1) dp[i][j][k]=0; } } vector> A[301]; ll p,q,c; rep(i,m){ cin>>p>>q>>c; A[p].push_back({q,c}); dp[2][q][c]++; } for(int i=2;i<=n-1;i++){ for(int j=1;j<=300;j++){ for(int k=0;k<=K;k++){ for(auto x:A[j]){ if(k+x.second>K) continue; dp[i+1][x.first][k+x.second]=(dp[i+1][x.first][k+x.second]+dp[i][j][k])%MOD; } } } } ll ans; for(int j=1;j<=300;j++){ ans=(ans+dp[n][j][K])%MOD; } cout<