#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define rep(i, n) for(int i=0;i=0;--i) const int inf=1e9+7; const ll mod=1e9+7; const ll big=1e18; const double PI=2*asin(1); ll DP[305][305][305]; int main() { int N, M, K; cin>>N>>M>>K; vector > > edge(305); ll P, Q, C; map amap; for(int i=0;i>P>>Q>>C; P--; Q--; edge[P].push_back(mp(Q, C)); } for(int i=0;i<305;++i){ DP[0][0][i] = 1; } for(int i=0;iK) continue; DP[i+1][j+edge[k][l].se][edge[k][l].fi] += DP[i][j][k]; DP[i+1][j+edge[k][l].se][edge[k][l].fi] %= mod; } } } } ll ans = 0; for(int k=0;k<305;++k) { ans += DP[N-1][K][k]; ans %= mod; } cout<