#P9454. [ZSHOI-R1] 巡城
[ZSHOI-R1] 巡城
Background
After many years of development by the king of Country X, her country has undergone a major transformation and stood out from those countries that have cities but only roads. In other words, Country X is no longer a tree, but a graph.
Problem Description
In order to centralize her power and stabilize the city-states, the king has very strict requirements on the road design: between any two cities, there is at most one path that does not pass through the capital. However, no one knows why this can better stabilize Country X.
One day, the king of Country X decided to visit all the cities. She informed all the cities of this good news by radio the day before the tour. The enthusiastic people also responded actively, preparing to welcome the king.
The king can visit only one city per day, and on the first day she will start from the capital.
On each following day, she will randomly choose with equal probability one unvisited city from the cities directly connected to her current city, and go there. If there is no such city, she will immediately return along the original path, going back via the road she used to arrive at this city, and then repeat the above process. Because there is a portal carrying cosmic rays, this returning process does not consume time.
The people who love her want to know the expected date when their king arrives at their city for the first time (the day she visits the capital is counted as , and then it increases by once per day). Output the answer modulo .
It is guaranteed that the graph formed by the cities is connected, has no self-loops or multiple edges, and the capital is numbered .
Input Format
The first line contains two integers , representing the number of cities and the number of roads in Country X.
The next lines each contain two integers , indicating a road between the two cities.
Output Format
There is line containing integers.
The -th integer represents the expectation for city .
3 2
1 2
2 3
1 2 3
4 3
1 2
2 3
2 4
1 2 499122180 499122180
5 7
5 4
2 4
4 3
1 3
1 2
1 4
1 5
1 249561092 249561092 249561091 249561092
Hint
For all testdata, , . | Data Point | n | m | | :----------: | :----------: | :----------: | | 1~2 | | | | 3~5 | | | | 6~8 | | | | 9~10 | | | | 11~15 | | | | 16~20 | | |
Translated by ChatGPT 5