#include using namespace std; const long long int MOD = 1e9 + 7; vector > adj[301]; long long int dp[301][301][301]; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int N, M, K, a, b, c; cin >> N >> M >> K; for (int i = 0; i < M; i++) { cin >> a >> b >> c; adj[a].push_back(make_pair(b, c)); } for (int i = 1; i <= 300; i++) { dp[1][i][0] = 1; } for (int i = 1; i < N; i++) { for (int j = 1; j <= 300; j++) { for (int k = 0; k <= K; k++) { if (dp[i][j][k] == 0) { continue; } for (auto it : adj[j]) { int x = it.first; int y = it.second; if (k + y <= K) { dp[i + 1][x][k + y] += dp[i][j][k]; dp[i + 1][x][y + k] %= MOD; } } } } } long long int res = 0; for (int i = 1; i <= 300; i++) { res += dp[N][i][K]; res %= MOD; } cout << res << '\n'; return 0; }