#include #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair ; using pll = pair; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; int n,m,k; vector> graph(305,vector

()); ll dp[305][305][305] = {-1}; ll dfs(int i,int cnt,int cost){ if(dp[i][cnt][cost]>=0) return dp[i][cnt][cost]; if(cnt==0){ if(cost==0) return 1; else return 0; } ll res = 0; rep(j,graph[i].size()){ if(cost-graph[i][j].first<0) continue; ll p = dfs(graph[i][j].second,cnt-1,cost-graph[i][j].first); res = (res + p)%MOD; } return dp[i][cnt][cost] = res; } int main(){ rep(i,305)rep(j,305)rep(k,305) dp[i][j][k] = -1; cin >> n >> m >> k; rep(i,m){ int p,q,c; cin >> p >> q >> c; graph[p].push_back(P(c,q)); } for(int i=1;i<305;i++) graph[0].push_back(P(0,i)); cout << dfs(0,n,k) << endl; return 0; }