Museum#967

Museum

1 saniye
256 megabayt
Orta

In the capital city of Olympia, the Museum of Olympic Glory has been established to showcase the awards won by the country's schoolchildren in various subject Olympiads. The museum consists of exhibition halls interconnected by corridors, with each corridor connecting exactly two halls. It is known that any hall in the museum can be reached from any other hall by traversing these corridors. Additionally, the number of corridors is equal to the number of halls.

At night, the museum is patrolled by guards. The number of guards is equal to the number of halls, with each guard stationed in a specific hall. Every hour, according to a predetermined patrol plan, some guards move to a different hall while others remain in place. The patrol plan adheres to the following conditions:

  1. For each hall, the plan indicates whether its guard stays or moves to an adjacent hall connected by a corridor.

  2. After all guards have moved, there must be exactly one guard in each hall.

  3. The same patrol plan is applied every hour.

For example, the diagram illustrates one possible patrol plan. Every hour, the guard in hall moves to hall ; the guard in hall moves to hall ; the guard in hall moves to hall ; the guards in halls and swap places; the guard in hall remains in the same hall throughout the night.

Write a program that, given information about the number of museum halls and their corridor connections, calculates the number of distinct patrol plans for the museum, modulo .

Giriş

The first line contains two integers: (3 \leq N \leq 50000), the number of halls in the museum, and (2 \leq P \leq 10000). The following lines each contain a pair of integers from to , representing the numbers of the halls connected by a corridor.

Çıktı

Output a single integer — the number of patrol plans for the museum, modulo (the remainder when the total number of plans is divided by ).

Explanation of the example: There are different patrol plans: (1, 2, 3, 4, 5, 6), (1, 2, 3, 5, 4, 6), (1, 2, 3, 6, 5, 4), (1, 2, 4, 3, 5, 6), (1, 3, 2, 4, 5, 6), (1, 3, 2, 5, 4, 6), (1, 3, 2, 6, 5, 4), (2, 1, 3, 4, 5, 6), (2, 1, 3, 5, 4, 6), (2, 1, 3, 6, 5, 4), (2, 1, 4, 3, 5, 6), (2, 3, 1, 4, 5, 6), (2, 3, 1, 5, 4, 6), (2, 3, 1, 6, 5, 4), (3, 1, 2, 4, 5, 6), (3, 1, 2, 5, 4, 6), (3, 1, 2, 6, 5, 4), (3, 2, 1, 4, 5, 6), (3, 2, 1, 5, 4, 6), (3, 2, 1, 6, 5, 4). The depicted plan in the diagram is (2, 3, 1, 5, 4, 6).

Örnekler

Örnek 1

Loading
Loading