Servicing Clients

No attempts yetTime limit1sMemory limit128 MB

Problem

One facility and several clients sit at some of the vertices of a weighted graph G=(V,E)G = (V, E). Every client jj comes with a nonnegative demand djd_j and a nonnegative priority pjp_j that says how important that client is.

The servicing cost of client jj is cj×djc_j \times d_j, where cjc_j is the shortest distance in GG from the facility vertex to the vertex of client jj. In the figure below the servicing cost of client aa is 3×da3 \times d_a, where dad_a is the demand of client aa. The servicing cost of client bb in the same figure is infinite, because no path connects client bb to the facility.

Write a program that picks a subset of the client set whose total servicing cost stays within a nonnegative budget BB and whose total priority is as large as possible.

Input

Your program reads from standard input. The first line contains the number of test cases TT. (1T201 \le T \le 20)

Each test case starts with a line containing the number of vertices NN of the graph. (1N1001 \le N \le 100) The vertices are numbered from 00 to N1N-1, and the facility sits at vertex 00.

The next line contains the number of clients MM. (0M1000 \le M \le 100) Each of the next MM lines describes one client with three integers: the vertex the client sits at, the demand, and the priority. The vertex number is between 00 and N1N-1, and the demand and the priority are each between 00 and 100100.

The next line contains the total budget BB. (0B1000 \le B \le 100)

The next line contains the number of edges LL. (0L1000 \le L \le 100) Each of the next LL lines describes one edge with three integers: the two vertices the edge joins, then the cost of the edge. The vertex numbers are between 00 and N1N-1 and the cost is between 00 and 100100. Edges have no direction.

Output

Your program writes to standard output. For each test case, print one line with the total priority of the clients selected for service.