import sys
input = sys.stdin.readline

mod=10**9+7

N,M,K=map(int,input().split())

E=[tuple(map(int,input().split())) for i in range(M)]

DP=dict()
DP=[[0]*(K+1) for i in range(301)]
for i in range(1,301):
    DP[i][0]=1

for i in range(N-1):
    NDP=[[0]*(K+1) for i in range(301)]

    for fr,to,cost in E:
        for j in range(301):
            if j+cost<=K:
                NDP[to][j+cost]+=DP[fr][j]
                NDP[to][j+cost]%=mod

    DP=NDP
                    
ANS=0
for i in range(301):
    ANS=(ANS+DP[i][K])%mod
print(ANS)