Luka owns a geographic data company that maintains a detailed city map and exports the data to interested parties. Often, clients do not want the complete map. Instead, they want a simplified map containing only major streets.
City map is an undirected graph consisting of intersections denoted with integers from to and two-way streets. Each street is assigned a priority - a non-negative integer. When requesting a map, the client selects a threshold priority . The original map is then copied and converted to the exported map using the following procedure:
All streets whose priority is lower than are deleted.
For each intersection from , , . . . , (processed in that order):
(a) If the intersection is not connected to any streets it is deleted.
(b) If the intersection is connected to exactly two different streets and leading to intersections and both different from then the intersection is contracted using the following procedure:
Streets and are deleted.
Intersection is deleted.
New street connecting intersections and is added.

Illustration of the second example with the threshold priority
Initially, the map does not contain loops (loop is a street that connects an intersection to itself) or parallel edges (more than one street between the same pair of intersections), but the loops and parallel edges may form during the contraction procedure. Notice that, in the step 2. (b) above, neither nor can be a loop (both and have to be different from ), but the newly added street could be a loop (it is possible that and are same).
Given a map and a sequence of incoming export requests, for each request find the number of intersections and the number of streets in the exported map.
The first line contains two integers (1 \leq n \leq 300\,000) and (1 \leq m \leq 300\,000) – the number of intersections and the number of streets, respectively. Each of the following lines contains three integers , and (1 \leq a, b \leq n, 0 \leq p \leq 300\,000) which describe a street with priority connecting intersections and . No street connects an intersection to itself. There is at most one street between every two intersections.
The following line contains an integer (1 \leq q \leq 300\,000) - the number of export requests. The following line contains integers. The -th integer t_k (0 \leq t_k \leq 300\,000) is the threshold priority of the -th request.
Output should consist of lines. The -th line should contain two integers - the number of intersections and the number of streets, respectively, in the exported map for the -th request.
Example 1
Example 2