Tree Subset Diameter
题号:NC17498
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
Special Judge, 64bit IO Format: %lld

题目描述

You are given an undirected, unweighted tree T on n nodes. We define the distance between two nodes u, v as the number of edges we need to travel from u to v. We define the diameter of a subset of nodes S as the maximum distance between two elements in S. If the size of S is smaller than or equal to 1, we define the diameter as 0.

Find the number of subsets S of nodes in T such that the diameter of S is exactly D.

输入描述:

The first line of input contains a single integer n (2 ≤ n ≤ 100000).

The next n - 1 lines contains two space-separated integers each, ui, vi (1 ≤ ui ≠ vi ≤ n), describing an edge of the tree connecting ui and vi.

The last line contains a single integer D (1 ≤ D ≤ n).

It is guaranteed that the input graph is a tree.

输出描述:

Output a single integer, the number of subsets of nodes with diameter D. Since the answer might be large, output it modulo 109 + 7.
示例1

输入

复制
4
2 3
1 3
3 4
2

输出

复制
8

说明

For the first sample, the subsets are {1, 2}, {1, 4}, {2, 4}, {1, 2, 3}, {1, 3, 4}, {2, 3, 4}, {1, 2, 4}, {1, 2, 3, 4}.
示例2

输入

复制
4
2 3
1 3
3 4
1

输出

复制
3

说明

For the second sample, the subsets are {1, 3}, {2, 3}, {3, 4}.