## KEQUALITY - Kingdom of Equality

There is a kingdom called DomKi. There are ** N** cities and

**bidirectional roads in DomKi. The cities of DomKi are connected to each other in such a way that it forms a Tree.**

*N – 1*Recently a dangerous virus called corona has attacked the kingdom and the people in several cities are affected by the disease COVID-19 (which is caused by the corona virus). The infection of the virus has been declared as an epidemic in DomKi.

As COVID-19 - spreads from person to person in close proximity, similar to other respiratory illnesses, such as the flu, some cities in DomKi are under lockdown to ensure social distancing.

Due to lockdown, some roads also became unavailable to use.

Now there is a group of people who may stay in different cities. For an important issue they all want to meet in a specific city if possible. But there is a strange rule is followed by them. They all want to choose a city in such a way that the selected city is reachable by all of them and everyone has to travel the same distance from their residence city to the selected city through the shortest path.

**The distance between two cities in DomKi is the number of roads between them in the shortest path.**

Suppose there are 10 cities in DomKi numbered from 1 to 10 and 9 roads shown in the above picture. The number (** 0 or 1**) associated with each road determines whether this road is available or not (

**).**

*Note that, 0 means the road is not available and 1 means available*Let there is a group consist of

**2**people, numbered

**4**and

**6**, wants to meet each other. Then there is a possible set (say

**) of**

*S***4**different cities they can select to meet which is,

**. The shortest distance from city**

*S = {2, 1, 3, 7}***4**to each city in

**and city**

*S***6**to each city in

**is**

*S***identical.**

**Note that, city 5, 9 and 10 are also same distance away from city 4 and 6 but they are not reachable.**

Now the task is to count the size of the set

**for a given group of people.**

*S***It is to be observed that, a group may consist of 1 people also.**

### Input

The first line of the input contains a positive integers **N**, denotes the number of cities in the kingdom.

The next **N - 1** lines contains the description of the roads .

Each road is described by three positive integers **u, v, k**, where **u** and **v** denotes two cities which is connected by this road and **k** denotes the availability of the road (**0** or **1**).

The next line contains a positive integer **Q**, denotes the number of query.

Each of the next **Q** lines will describe a group of people, which is a query to be answered .

Each line will begin with a positive integer **g**_{i}, which denotes the number of people in the **i**^{th} group. Then in the same line **g**_{i} space separated numbers will be given which denotes the cities where the people of this group reside.**Note, that there can be more than one people in each city.****1 ≤ N, Q, u, v ≤ 2 × 10 ^{5}**.

**u != v**.

**1 ≤ u, v ≤ N**

**0 ≤ k ≤ 1.**

**1 ≤ g**

_{i}

**≤ 2 × 10**

^{5}**Sum of all**

**g**

_{i}

**≤ 2 × 10**

^{5}.### Output

For each query output **the size of the set S** in a new line which is described in the problem statement.

### Example

Input:10 1 2 1 1 3 1 3 7 1 2 4 1 2 6 1 2 5 0 5 9 1 5 10 1 4 8 1 1 2 4 6Output:

4

Added by: | Prodip |

Date: | 2020-05-12 |

Time limit: | 1s |

Source limit: | 50000B |

Memory limit: | 1536MB |

Cluster: | Cube (Intel G860) |

Languages: | All |