#abc284g. [abc284_g]Only Once
[abc284_g]Only Once
Problem Statement
For a sequence of length , , consisting of integers between and , inclusive, and an integer , let us define a sequence of length , , as follows.
- .
- .
Additionally, let us define as the number of distinct integers that occur exactly once in the sequence . More formally, is the number of values such that exactly one index satisfies .
You are given an integer . There are sequences that can be . Find the sum of over all of them, modulo .
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
4 100000000
Sample Output 1
624
As an example, let us consider the case .
- For : we have , where two integers, and , occur exactly once, so .
- For : we have , where one integer, , occurs exactly once, so .
- For : we have , where no integers occur exactly once, so .
- For : we have , where no integers occur exactly once, so .
Thus, we have .
If we similarly compute for the other sequences, the sum of this value over all sequences is .
Sample Input 2
7 1000000000
Sample Output 2
5817084
Sample Input 3
2023 998244353
Sample Output 3
737481389
Print the sum modulo .
Sample Input 4
100000 353442899
Sample Output 4
271798911