You are gifted a tree consisting of vertices. There are two types of edges each with a weight and denoted by a value that is either or . A pair , where is called GOOD if, while traversing from vertex to vertex , we never pass through an edge of 0.
Your task is to calculate the sum of the path’s weight of all the GOOD pairs present in the tree. Print the final answer modulo .
Input Format:
Output format:
For each test case, print an integer denoting the sum of the path's weight of all the GOOD pairs modulo .
Constraints:
It is guaranteed that the input graph forms a tree.
In the first test case, there is only one GOOD pair, i.e. (2, 3) and the weight of the edge is 3.
In the second test case, the GOOD pairs are (1, 2), (1, 3), and (2, 3), and the sum of weights for all the three paths are 5, 7, and 12. Thus, the output is 24.