#include #include #include #include #include #include #include #include using namespace std; using ll = long long; using vi = vector; #define in(v) v; cin >> v; void ins() {} templatevoid ins(T& v,Rest&... rest){cin>>v;ins(rest...);} #define rep(i,n) for(int i=0,_i=(n);i<_i;++i) #define rrep(i,n) for(long long i=(n);i>=0;--i) #define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c)) // ========== debug ========== templateostream& operator<<(ostream& os,const vector& vec){os<<"{";for(size_t i=0;i&v){for(size_t i=0;iostream& operator<<(ostream& os,const pair& rhs){os<<"("< void debug(const First& first) {cerr< void debug(const First& first, const Rest&... rest) {cerr< void debug2(const First& first) {cerr< void debug2(const First& first, const Rest&... rest) {cerr<> edge; Graph(int n = 0) { resize(n); } void resize(int n) { edge.resize(n, map()); } void addEdge(int from, int to, long long weight, bool directed = false) { edge[from][to] = weight; if (!directed) edge[to][from] = weight; } map& operator[](int from) { return edge[from]; } }; template struct MInt { long long val; constexpr MInt(long long val = 0) : val(val % MOD) { if (val < 0) val += MOD; } MInt operator-() const { return MInt(-val); } MInt operator+(const MInt& n) const { return MInt(val) += n; } MInt operator-(const MInt& n) const { return MInt(val) -= n; } MInt operator*(const MInt& n) const { return MInt(val) *= n; } MInt operator/(const MInt& n) const { return MInt(val) /= n; } MInt& operator+=(const MInt& n) { val = (val + n.val) % MOD; return *this; } MInt& operator-=(const MInt& n) { val = (MOD + val - n.val) % MOD; return *this; } MInt& operator*=(const MInt& n) { val = (val * n.val) % MOD; return *this; } MInt& operator/=(const MInt& n) { val = (*this * n.inv()).val; return *this; } bool operator==(const MInt& n) { return val == n.val; } bool operator!=(const MInt& n) { return val != n.val; } MInt pow(long long n) const { MInt pow = val, ans = 1; for (long long p = n; p > 0; p >>= 1, pow *= pow) if (p & 1) ans *= pow; return ans; } MInt inv() const { return pow(MOD-2); } friend ostream& operator<<(ostream& os, const MInt& n) { os<>(istream& os, MInt& n) { os>>n.val; return os; } }; constexpr int MOD = 1e9+7; // constexpr int MOD = 998244353; using mint = MInt; bool visited[300][301][301]; mint memo[300][301][301]; mint dfs(Graph &G, int start, int N, int K) { if (N == 0) return K == 0; if (K < 0) return 0; if (visited[start][N][K]) return memo[start][N][K]; visited[start][N][K] = true; mint ans = 0; for (const auto& [to, c]:G[start]) { ans += dfs(G, to, N-1, K-c); } return memo[start][N][K] = ans; } int main() { int N, M, K; ins(N, M, K); Graph G(300); rep(i, M) { int P, Q, C; ins(P, Q, C); --P, --Q; G.addEdge(P, Q, C, true); } mint ans = 0; rep(i, N) { ans += dfs(G, i, N-1, K); } cout << ans << endl; return 0; }