#P6803. [CEOI 2020] 星际迷航
[CEOI 2020] 星际迷航
Description
The Interstellar Federation consists of planets, numbered . Some planets are connected by interstellar passages. Through these passages, a spaceship can travel back and forth between planets in a short time. There are exactly interstellar passages in the whole federation, and using these passages, it is possible to travel between any two planets.
Besides our universe, there are parallel universes. These parallel universes are exact copies of our universe: their planets and interstellar passages are exactly the same as ours. We number these parallel universes as (our universe is numbered ), and denote the -th planet in the -th universe by . Using stargates, we can travel among these parallel universes. For all , we will choose one and one (with ), and build a one-way (only from to ) stargate between and .
After all stargates are ready, the Federation starship Batthyány will start its maiden voyage. It is currently orbiting planet . Captain Ágnes plans to play the following game with Lieutenant Gábor: the two players alternately choose the next destination of the starship, and the destination must be directly reachable via an interstellar passage or a stargate. They want each visited planet to be one that has not been visited before. That is, if the starship arrives at , then they will never pass through that planet again (but they may still arrive at the corresponding planet in other parallel universes). Captain Ágnes moves first, Lieutenant Gábor moves second. If a player, on their turn, cannot choose a legal destination, then that player loses the game.
Both the captain and the lieutenant are perfectly smart. They know the full layout of all interstellar passages and stargates, and they always play optimally. You need to find how many stargate layouts make Captain Ágnes (the first player) guaranteed to win. Two stargate layouts are different if and only if there exists an integer such that or is different.
Input Format
The first line contains two integers , representing the number of planets in the federation and the number of parallel universes.
The next lines each contain two integers , meaning that for all , there is an interstellar passage connecting and .
Output Format
Output the number of stargate layouts that make the captain guaranteed to win, modulo .
3 1
1 2
2 3
4
Hint
Sample Explanation
There are essentially different stargate layouts in total. Four winning cases for the captain are listed below.

Subtasks
All testdata satisfy: , , .
The constraints for each subtask are as follows:
| Subtask ID | Points | Constraints |
|---|---|---|
| Sample | ||
| , | ||
| , | ||
| , | ||
| No special constraints. |
Translated by ChatGPT 5
京公网安备 11011102002149号