#agc021f. [agc021_f]Trinity
[agc021_f]Trinity
Problem Statement
We have an grid. The square at the -th row and -th column will be denoted as . Particularly, the top-left square will be denoted as , and the bottom-right square will be denoted as . Takahashi painted some of the squares (possibly zero) black, and painted the other squares white.
We will define an integer sequence of length , and two integer sequences and of length each, as follows:
- is the minimum such that is painted black, or if it does not exist.
- is the minimum such that is painted black, or if it does not exist.
- is the maximum such that is painted black, or if it does not exist.
How many triples can occur? Find the count modulo .
Notice
In this problem, the length of your source code must be at most B. Note that we will invalidate submissions that exceed the maximum length.
Constraints
- and are integers.
Partial Score
- points will be awarded for passing the test set satisfying .
Input
Input is given from Standard Input in the following format:
Output
Print the number of triples , modulo .
Sample Input 1
2 3
Sample Output 1
64
Since , given and , we can uniquely determine the arrangement of black squares in each column. For each , there are four possible pairs : , , and . Thus, the answer is .
Sample Input 2
4 3
Sample Output 2
2588
Sample Input 3
17 13
Sample Output 3
229876268
Sample Input 4
5000 100
Sample Output 4
57613837