URI Online Judge | 2789
# Water Crisis

**Timelimit: 3**

By Dâmi Henrique Brazil

Montes Claros, a city in the north of Minas Gerais, has been undergoing a major water crisis in recent times. Scarcity of water has affected the lives of many residents, making them put their homes up for sale at a price well below the market. Abbade, a major investor, sees this crisis moment as an investment opportunity and intends to buy several of these houses.

There are **N** houses in Montes Claros and **M** of them are for sale. A curious fact is that there is only one way between any pair of houses and it is possible, from any house, to reach all the others in the city.

Because of the crisis, **Q**-water trucks pass monthly through the city streets. The i-th of these trucks makes the way from a certain home **X**_{i} to another **Y**_{i} home, leaving **L**_{i }gallons of water in each house on its way.

Abbade has **D** reais to invest in the purchase of houses. However, since he fears that the crisis will get worse and real estate will never be resold, he will buy the houses so that the sum of the amount of water received by the trucks in those houses is as large as possible. To decide which houses to buy, he asked for his help.

The first line contains two **N** and **D** integers separated by space, representing the number of houses in the city and the money that Abbade owns for the purchase of the houses. Each house is identified by an integer between 1 and **N**. Follow **N**-1 lines. The i-th of them will contain two integers, **A**_{i} and **B**_{i}, meaning that there is a direct route

between these houses.

The next line will contain an integer **M**, indicating the number of homes that are for sale. Follow **M** lines. The i-th of them will contain two integers **C**_{i} and **V**_{i}, where **C**_{i} is the number of one of the houses and **V**_{i }its selling price. It is guaranteed that a house will not appear more than once.

The next line will contain an integer **Q**, indicating the number of water trucks that will pass through the city. Follow the **Q** lines. The i-th of these lines will contain three integers** X**_{i}, **Y**_{i} and **L**_{i}, indicating that the i-th truck will depart from house **X**_{i} to house **Y**_{i} leaving **L**_{i} liters of water in each of the houses along the way.

1 ≤ **N **≤ 5 × 10^{3}

1 ≤ **D** ≤ 10^{3}

1 ≤ **M** ≤ **N**

1 ≤ **V**_{i} ≤ 100

1 ≤ **Q** ≤ 5 × 105

1 ≤ **L** ≤ 103

Write in the output a line containing an integer: as much water as the houses Abbade will buy will receive, since he will buy houses in order to maximize that value.

Input Sample | Output Sample |

6 10 |
13 |