Time limit: 0.6s
Memory limit: 256MB
Input:
Output:
Task
You are given an integer . Consider all the labeled undirected graphs with vertices. For each such graph, count the number of critical edges in it. Find the sum of the number of critical edges for all undirected graphs with vertices.
An edge is critical if by removing it, the number of connected components increases.
Since this number can be very large, print it modulo , where is a prime number.
Input data
The first line of the input will contain the numbers and .
Output data
Print a single integer, the sum of the number of critical edges for all undirected graphs with vertices.
Constraints and clarifications
- , is prime.
# | Points | Constraints |
---|---|---|
1 | 11 | |
2 | 53 | |
4 | 36 | No additional constraints. |
Example 1
stdin
6 2017
stdout
1254
Example 2
stdin
319 666013
stdout
385993