atcoder#AGC021F. [AGC021F] Trinity
[AGC021F] Trinity
Score : points
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:
N M
Output
Print the number of triples , modulo .
2 3
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 .
4 3
2588
17 13
229876268
5000 100
57613837