A=10**9+7 N,M,K=map(int,input().split()) S=300 E=[[] for _ in range(S+1)] F=[[] for _ in range(S+1)] for _ in range(M): p,q,c=map(int,input().split()) E[p].append((q,c)) F[q].append((p,c)) X=[[[0]*(K+1) for _ in range(S+1)] for _ in range(N)] for f in range(1,S+1): X[0][f][0]=1 for n in range(1,N): for a in range(1,S+1): for k in range(K+1): for (q,c) in F[a]: if k>=c: X[n][a][k]=(X[n][a][k]+X[n-1][q][k-c])%A Y=0 for a in range(1,S+1): Y=(Y+X[-1][a][-1])%A print(Y)