#include /*#include #include */#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; /*namespace mp = boost::multiprecision; using Bint = mp::cpp_int; using Real = mp::number>; */#define lli long long int #define uli unsigned long long int #define INF 999999999999 #define rep(i,m,n) for(lli i = m;i < n;i++) #define rrep(i,m,n) for(lli i=m-1;i>=n;i--) #define pb(n) push_back(n) #define UE(N) N.erase(unique(N.begin(),N.end()),N.end()); #define Sort(n) sort(n.begin(), n.end()) #define Rev(n) reverse(n.begin(),n.end()) #define Out(S) cout << S << endl #define NeOut(S) cout << S #define HpOut(S) cout << setprecision(50) << S << endl #define Vec(K,L,N,S) vector K(N,S) #define DV(K,L,N,M,S) vector> K(N,vector(M,S)) #define TV(K,L,N,M,R,S) vector>> K(N,vector>(M,vector(R,S))) #define pint pair #define paf(L,R) pair #define mod 1000000007 #define MAX 10000000 #define ALL(a) a.begin(),a.end() #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) struct edge{ int first; int second; }; int main(){ ios::sync_with_stdio(false); cin.tie(0); lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T; cin >> N >> M >> K; vector> P(N); rep(i,0,M){ cin >> A >> B >> C; edge e; e.first=B-1; e.second=C; P[A-1].pb(e); } TV(dp,lli,400,400,400,0); rep(i,0,400)dp[0][i][0]=1; rep(i,1,N+1){ rep(j,0,N)for(auto v:P[j]){ rep(k,0,K+10){ if(k+v.second<350)dp[i][v.first][k+v.second]=(dp[i-1][j][k]+dp[i][v.first][k+v.second])%mod; } } } rep(i,0,N)sum+=dp[N-1][i][K]%mod; Out(sum%mod); }