#include using namespace std; #define int long long #define REP(i,m,n) for(int i=(m);i<(n);i++) #define rep(i,n) REP(i,0,n) #define pb push_back #define all(a) a.begin(),a.end() #define rall(c) (c).rbegin(),(c).rend() #define mp make_pair #define endl '\n' typedef long long ll; typedef pair pll; typedef long double ld; const ll inf=1e9+7; const ll mod=1e9+7; signed main(){ ll n,m,k;cin>>n>>m>>k; vector > >dp(n+1,vector >(301,vector(k+1))); rep(i,n){ dp[0][i][0]=1; } vector >a(m); rep(i,m){ ll p,q,c;cin>>p>>q>>c; p--; q--; a[i]=mp(mp(p,q),c); } rep(i,n-1){ rep(j,k+1){ rep(l,m){ ll p=a[l].first.first; ll q=a[l].first.second; ll c=a[l].second; if(j+c>k)continue; dp[i+1][q][j+c]=(dp[i+1][q][j+c]+dp[i][p][j])%inf; } } } ll ans=0; rep(i,n){ ans=(ans+dp[n-1][i][k])%inf; } cout<