In the village of graphs, there lived two researchers, Lena and Misha. They found a connected undirected graph consisting of $$$n$$$ vertices and $$$m$$$ edges.
Some edges had known positive weights, while others had unknown weights. Lena and Misha decided to determine how many ways there are to assign integer values from $$$1$$$ to $$$l$$$ inclusive to the edges with unknown weights so that, for each vertex $$$v$$$, the shortest path from vertex $$$1$$$ to vertex $$$v$$$ has length exactly $$$d_v$$$.
Since the number of possible assignments can be very large, the answer should be given modulo $$$10^9 + 7$$$.
Each test contains one or more test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 50$$$) — the number of test cases.
The descriptions of the test cases follow.
The first line of each test case contains three integers $$$n$$$, $$$m$$$, and $$$l$$$ ($$$2 \le n \le 50$$$; $$$n - 1 \le m \le \frac{n(n-1)}{2}$$$; $$$1 \le l \le 10^9$$$) — the number of vertices, the number of edges, and the maximum possible weight of an unknown edge.
The next $$$m$$$ lines describe the edges of the graph. Each edge is given by three integers $$$u_i$$$, $$$v_i$$$, $$$w_i$$$ ($$$1 \le u_i, v_i \le n$$$; $$$u_i \ne v_i$$$; $$$-1 \le w_i \le l$$$; $$$w_i \ne 0$$$) — the endpoints of the edge and its weight. If $$$w_i = -1$$$, the weight of this edge is unknown and can be chosen from $$$1$$$ to $$$l$$$. If $$$w_i \ne -1$$$, this is the known weight of the edge.
The last line of each test case contains $$$n$$$ integers $$$d_1, d_2, \dots, d_n$$$ ($$$0 \le d_v \le 10^{12}$$$), where $$$d_v$$$ is the required length of the shortest path from vertex $$$1$$$ to vertex $$$v$$$.
It is guaranteed that the graph is connected and contains no loops or multiple edges.
For each test case, output a single integer — the number of ways to assign weights to the edges with unknown weights from $$$1$$$ to $$$l$$$ such that, for every vertex $$$v$$$, the sum of the edge weights on the shortest path from vertex $$$1$$$ to vertex $$$v$$$ equals $$$d_v$$$, taken modulo $$$10^9 + 7$$$.
43 3 31 2 -12 3 -11 3 -10 1 13 2 31 2 -12 3 -10 1 23 3 31 2 -12 3 -11 3 -10 1 23 3 31 2 12 3 11 3 10 1 2
3 1 4 0