Manthan, Codefest 17
C
Helga Hufflepuff's Cup
Codeforces
2000
原题
← BD →
翻译中…

Harry, Ron and Hermione have figured out that Helga Hufflepuff's cup is a horcrux. Through her encounter with Bellatrix Lestrange, Hermione came to know that the cup is present in Bellatrix's family vault in Gringott's Wizarding Bank.

翻译中…

The Wizarding bank is in the form of a tree with total $*n*$ vaults where each vault has some type, denoted by a number between $1$ to $*m*$. A tree is an undirected connected graph with no cycles.

翻译中…

The vaults with the highest security are of type $*k*$, and all vaults of type $*k*$ have the highest security.

翻译中…

There can be at most $*x*$ vaults of highest security.

翻译中…

Also, if a vault is of the highest security, its adjacent vaults are guaranteed to not be of the highest security and their type is guaranteed to be less than $*k*$.

翻译中…

Harry wants to consider every possibility so that he can easily find the best path to reach Bellatrix's vault. So, you have to tell him, given the tree structure of Gringotts, the number of possible ways of giving each vault a type such that the above conditions hold.

翻译中…

Input

翻译中…

The first line of input contains two space separated integers, $*n*$ and $*m*$ — the number of vaults and the number of different vault types possible. ($1 ≤ *n* ≤ 10^{5}, 1 ≤ *m* ≤ 10^{9}$).

翻译中…

Each of the next $*n* - 1$ lines contain two space separated integers $*u*_{*i*}$ and $*v*_{*i*}$ ($1 ≤ *u*_{*i*}, *v*_{*i*} ≤ *n*$) representing the $*i*$-th edge, which shows there is a path between the two vaults $*u*_{*i*}$ and $*v*_{*i*}$. It is guaranteed that the given graph is a tree.

翻译中…

The last line of input contains two integers $*k*$ and $*x*$ ($1 ≤ *k* ≤ *m*, 1 ≤ *x* ≤ 10$), the type of the highest security vault and the maximum possible number of vaults of highest security.

翻译中…

Output

翻译中…

Output a single integer, the number of ways of giving each vault a type following the conditions modulo $10^{9} + 7$.

翻译中…

Note

翻译中…

In test case $1$, we cannot have any vault of the highest security as its type is $1$ implying that its adjacent vaults would have to have a vault type less than $1$, which is not allowed. Thus, there is only one possible combination, in which all the vaults have type $2$.

翻译中…

样例

Input #1
4 2
1 2
2 3
1 4
1 2
Output #1
1
InputCopy OutputCopy
Input #2
3 3
1 2
1 3
2 1
Output #2
13
InputCopy OutputCopy
Input #3
3 1
1 2
1 3
1 1
Output #3
0
InputCopy OutputCopy
题目信息
题号
855C
时间限制
2 s
内存限制
256 MB
标签
动态规划
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。