n,m,k = map(int,input().split()) PQC = [list(map(int,input().split())) for i in range(m)] mod = 10**9+7 s = 300 dp = [[0]*(k+1) for i in range(s)] for i in range(s): dp[i][0] = 1 for i in range(n-1): ndp = [[0]*(k+1) for i in range(s)] for p,q,c in PQC: p,q = p-1,q-1 for j in range(k+1): if dp[p][j] == 0: continue if j+c <= k: ndp[q][j+c] += dp[p][j] ndp[q][j+c] %= mod dp = ndp ans = 0 for i in range(s): ans += dp[i][k] ans %= mod print(ans)