#P1768E. Partial Sorting
Partial Sorting
Description
Consider a permutation of length . Each time you can do one of the following operations:
- Sort the first elements in increasing order.
- Sort the last elements in increasing order.
We can show that every permutation can be made sorted in increasing order using only these operations. Let's call the minimum number of these operations needed to make the permutation sorted in increasing order.
Given , find the sum of over all permutations of size .
Since the answer could be very large, output it modulo a prime .
A permutation of length is an array consisting of distinct integers from to in arbitrary order. For example, is a permutation, but is not a permutation ( appears twice in the array), and is also not a permutation ( but there is in the array).
The only line of input contains two numbers and (, ). It is guaranteed that is a prime number.
Output the answer modulo .
Input
The only line of input contains two numbers and (, ). It is guaranteed that is a prime number.
Output
Output the answer modulo .
Note
In the first test case, all the permutations are:
- , which requires operations;
- , which requires operation;
- , which requires operation;
- , which requires operations;
- , which requires operations;
- , which requires operations.
Therefore, the answer is .