Problem:
You have a Tree with N nodes rooted at 1 where node is associated with a value . Now consider the following definition:
K-Tuple: A tuple of nodes is a K-Tuple if:
1.) is an ancestor of
2.)
Calculate the number of K-Tuples in the tree.
Input:
First line contains two integers N and K, the number of nodes in the tree and the value for the Tuple type you need to calculate answer for.
Next line contains N space separated integers where the integer denotes the value .
Next lines contains X and Y denoting that there is an edge between them.
Output:
Output a single integer mod denoting the number of K-tuples in the tree.
Constraints:
There are 4 2-Tuples: (1,2,4), (1,2,5), (1,3,6), (1,3,7).