A=10**9+7 N,M,K=map(int,input().split()) S=300 E=[[] for _ in range(S+1)] for i in range(M): p,q,c=map(int,input().split()) E[p].append((q,c)) H={(F,0,0):1 for F in range(1,S+1)} def f(F,R,L): """ F:From R:残り複雑度 L:残りコード数 """ if (F,R,L) in H: return H[(F,R,L)] if L==0: return 0 K=0 for (q,c) in E[F]: if R>=c: K=(K+f(q,R-c,L-1))%A H[(F,R,L)]=K return K V=0 for i in range(1,S+1): V=(V+f(i,K,N-1))%A print(V%A)