Problem:
You have a Tree with N nodes rooted at 1 where \(i^{th}\) node is associated with a value \(A_i\). Now consider the following definition:
K-Tuple: A tuple of \(K+1\) nodes \((X_{1},X_{2},X_{3},\dots,X_{K+1})\) is a K-Tuple if:
1.) \(X_{i}\) is an ancestor of \(X_{i+1} \forall 1 \leq i \leq K\)
2.) \(A_{X_{i}} > A_{X_{i+1}} \forall 1 \leq i \leq K \)
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 \(i^{th}\) integer denotes the value \(A_i\).
Next \(N-1\) lines contains X and Y denoting that there is an edge between them.
Output:
Output a single integer mod \((10^9+7)\) denoting the number of K-tuples in the tree.
Constraints:
\( 1 ≤ N,A_i ≤ 100000 \)
\( 1 ≤ X,Y ≤ N \)
\( 1 ≤ K ≤ 20 \)