Time Limit:24000ms
Case Time Limit:4000ms
Memory Limit:512MB

### Description

Little Y has a tree of n nodes with each edge having a positive weight.

Little J has q queries, each time he will delete k edges in the tree.

Then the tree is splitted into k+1 connected componets.

Little J wants to know the sum of the distance of farthest pair of points in each connected components.

(0 when one component only has one node.)

Each query is independent with each other. This means each query is based on the original tree.

### Input

First line with an integer n, indicating the number of nodes.

Then following n-1 lines, the i-th line with three integers ui, vi, wi, indicating the i-th edge weighted wi connects ui and vi.

Then following one line with an integer q, indicating the number of queries.

For each query, the first line with an integer k, then following one line with k integers, indicating the id of the deleted edges.

1<=n,q,Σk<=105,1<=w<=109

### Output

For each query, output one line with an integer indicating the sum.

Sample Input
Sample Output