n, m, k = map(int, input().split()) Edge = [[] for _ in range(300)] for _ in range(m): p, q, c = map(int, input().split()) p -= 1 q -= 1 Edge[p].append((q, c)) mod = 10**9 + 7 DP = [[[0 for _ in range(k + 1)] for _ in range(300)] for _ in range(n)] for i in range(300): DP[0][i][0] = 1 for i in range(n - 1): for j in range(300): for c in range(k + 1): if DP[i][j][c] > 0: for nj, nc in Edge[j]: if c + nc > k: continue DP[i + 1][nj][c + nc] += DP[i][j][c] DP[i + 1][nj][c + nc] %= mod ans = 0 for i in range(300): ans += DP[n - 1][i][k] ans %= mod print(ans)