#include #include #include #include #include #include #include using namespace std; #define int long long #define endl "\n" constexpr long long INF = (long long)1e18; constexpr long long MOD = 1'000'000'007; struct fast_io { fast_io(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); }; } fio; #define f first #define s second signed main(){ cout<,int>> in; vector>> dp; cin>>N>>M>>K; in.resize(M); dp.resize(N+1, vector>(K+1, vector(MAX))); for(int i = 0; i < M; i++){ cin>>in[i].f.f>>in[i].f.s>>in[i].s; } for(int i = 0; i < MAX; i++){ dp[0][0][i] = 1; } N--; for(int i = 0; i < N; i++){ for(int j = 0; j < M; j++){ for(int k = 0; k <= K; k++){ if(in[j].s + k <= K) { dp[i+1][in[j].s + k][in[j].f.s] += dp[i][k][in[j].f.f]; dp[i+1][in[j].s + k][in[j].f.s] %= MOD; } } } } int ans = 0; for(int i = 0; i < MAX; i++){ ans += dp[N][K][i]; // cout<<"i = "<