Quarantine
Time limit2sMemory limit256 MB
Count the sets of cities to lock on a tree so that no simple path with at least K roads joins two unlocked cities, modulo 10^9+7.
- Level
Hard8 of 10
- Topics
- Tree, Dynamic programming, Divide and conquer
- Solved
- No attempts yet
Problem
Seolgwak is a country of cities numbered from 1 to . Exactly roads connect pairs of cities, and every city is reachable from every other city. Every road has length .
Recently, a new virus that spread from the neighboring country Gyeonggwak has become widespread in Seolgwak. Minister of Health and Welfare Geunyeong believes that long-distance travel is the largest cause of the virus spreading. She plans to lock down some cities and close the roads connected to the locked cities.
For Geunyeong, a long-distance trip is a trip whose travel distance is at least and that does not pass through the same city more than once.
For example, suppose and the cities and roads are shaped as in the figure below.

A possible long-distance trip is the route that passes through cities 1, 2, 3, and 6 in order, or the route that passes through cities 5, 3, 6, and 7 in order. There are many other long-distance trips besides these.
If city 3 is locked, no route that avoids passing through the same city twice has length greater than 2, so long-distance travel becomes impossible. Locking every city also makes long-distance travel impossible.
Geunyeong wants to lock an appropriate set of cities so that long-distance travel is impossible. Count the number of ways to lock cities so that long-distance travel is impossible.
Input
The first line contains the number of cities and the positive integer that Geunyeong has in mind. ()
From the second line through the -th line, each line contains two positive integers and (). This means a road connects city and city .
Output
On the first line, print the number of ways to lock cities so that long-distance travel is impossible, modulo .