N = 300 n,m,k = map(int,input().split()) g = [[] for _ in range(N)] for _ in range(m): p,q,c = map(int,input().split()) g[p-1].append((q-1,c)) MOD = 10**9+7 dp = [[0]*(k+1) for _ in range(N)] for i in range(N): dp[i][0] = 1 for _ in range(n-1): ndp = [[0]*(k+1) for _ in range(N)] for i in range(N): for j,v in enumerate(dp[i]): if v==0: continue for q,c in g[i]: if j+c > k: continue ndp[q][j+c] += v ndp[q][j+c] %= MOD dp = ndp ans = 0 for i in range(N): ans += dp[i][-1] print(ans%MOD)