/* -*- coding: utf-8 -*- * * 1111.cc: No.1111 コード進行 - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 300; const int MAX_K = 300; const int CN = 300; const int MOD = 1000000007; /* typedef */ typedef pair pii; typedef vector vpii; /* global variables */ vpii nbrs[CN]; int dp[MAX_N][CN][MAX_K + 1]; /* subroutines */ inline void addmod(int &a, int b) { a = (a + b) % MOD; } /* main */ int main() { int n, m, k; scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < m; i++) { int p, q, c; scanf("%d%d%d", &p, &q, &c); p--, q--; nbrs[p].push_back(pii(q, c)); } for (int u = 0; u < CN; u++) dp[0][u][0] = 1; for (int i = 0; i + 1 < n; i++) for (int u = 0; u < CN; u++) for (int j = 0; j <= k; j++) if (dp[i][u][j] > 0) { vpii &nbr = nbrs[u]; for (vpii::iterator vit = nbr.begin(); vit != nbr.end(); vit++) { int v = vit->first, j1 = j + vit->second; if (j1 <= k) addmod(dp[i + 1][v][j1], dp[i][u][j]); } } int sum = 0; for (int u = 0; u < CN; u++) addmod(sum, dp[n - 1][u][k]); printf("%d\n", sum); return 0; }