import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines n, m=map(int, readline().split()) uabc=list(map(int, read().split())) u=uabc[:n] abc=uabc[n:] INF=10**12 d=[[INF]*n for i in range(n)] for i in range(n): d[i][i]=0 g=[[] for i in range(n)] for a, b, c in zip(*[iter(abc)]*3): d[a][b]=d[b][a]=c g[a].append(b) g[b].append(a) for k in range(n): for i in range(n): for j in range(n): d[i][j]=min(d[i][j], d[i][k]+d[k][j]) v=[] def dfs(x, p): v.append(x) for y in g[x]: if y!=p: dfs(y, x) dfs(0, -1) dp=[[-1]*(m+1) for i in range(n)] dp[0][0]=u[0] for i, x in enumerate(v): for y in v[:i]: for k in range(d[x][y], m+1): z=dp[y][k-d[x][y]] if z>=0 and dp[x][k]