You are given a tree of n nodes. Each of the n−1 edges of the tree is given by either '1' or '0'.
Then you need to answer q questions.
Each question has two integers k, m and a sequence of k nodes, a1,a2,…,ak. Let's call a sequence [a1,a2,…,ak] "good" if it satisfies the following criterion:
1. We will walk a path (possibly visiting same edge/node multiple times) on the tree, starting from a1 and ending at ak.
2. Start at a1, then go to a2 using the shortest path between a1 and a2, then go to a3 in a similar way, and so on, until you travel the shortest path between ak−1 and ak.
3. If you walked over at least m '1' edge (marked by '1') during this process, then the sequence is 'good'.

Consider the tree in the above figure. If m = 3, the following sequences are good: [8, 5], [8, 2, 6], [6, 0, 7, 8]. The following sequences are not good: [8, 0, 7], [3, 0, 7, 3], [8, 7, 0, 3].
Hint (You can jump to the Input/Output description first, and come back for hints if necessary):
1. The shortest path is unique.
2. In addition to a linked list, another approch is to use three 2D array to store the tree to save computational time.
3. If there is an edge between ai and ak, and another edge between ak and aj, then the distance between ai and aj is 2, and you can count the number of '1' edge at same time.
Use the tree above as an example:
The edge array will look like:

The (path & oneedge array) will look like:

The first line contains two integers n and q, the size of the tree and the number of questions, respectively.
Each of the next n−1 lines contains three integers ui, vi and xi (1 ≤ ui,vi ≤ n, xi ∈ {0,1}), where ui and vi denote the endpoints of the corresponding edge and xi denotes the edge is '0' or '1' .
Each of the next q lines contains k + 2 integers, k, m, and a sequence of k nodes.
testcase:
(1/6) 2 <= n <= 100, 1 <= q <= 100, k = 100, xi = 0
(3/6) 2 <= n <= 100, 1 <= q <= 100, k = 10
(2/6) 2 <= n <= 500, 1 <= q <= 1000, 2 <= k <= 10000
The output has q lines, if the sequence is good, output YES, otherwise output NO.