import sys input=sys.stdin.readline def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) def main(): mod=10**9+7 N,M,K=MI() MM=300 dp=[[[0]*(K+1) for _ in range(MM)]for _ in range(N)] #i個使った,j番目にいる,合計k for j in range(MM): dp[0][j][0]=1 pqc=[] for i in range(M): p,q,c=MI() p-=1 q-=1 pqc.append((p,q,c)) for i in range(N-1): for jj in range(M): fro=pqc[jj][0] to=pqc[jj][1] cost=pqc[jj][2] for k in range(K+1-cost): dp[i+1][to][k+cost]=(dp[i+1][to][k+cost] + dp[i][fro][k])%mod ans=0 for j in range(MM): ans=(ans + dp[-1][j][-1])%mod print(ans) main()