Kocke
Time limit2sMemory limit1024 MB
- Level
Not classified yet
- Solved
- No attempts yet
Statement
For his thirteenth birthday, Donald's parents bought him a brand new set of Lego cubes. The set has cubes of equal size, and the -th cube has color . Donald decides to build a wall with them.
Donald builds the wall on a row-like Lego base with places where cubes can be put. He places the cubes as follows:
- First, he puts the cube of color 1 on an arbitrary place on the base.
- For each cube from 2 to , he places it on a place neighboring the previously placed cube. If that place is not empty, he puts the new cube on top of the cubes already there.
After the wall is built, Donald writes a sequence of length on a piece of paper. The -th element is the color of the top cube on the -th place, or 0 if there is no cube there.
Donald asks himself how many different sequences he could have written. Two sequences are different if they differ at some position. He computed an answer but is not sure it is correct, so he asks for your help.
Input
The only line contains integers and (), the number of cubes and the length of the base.
Output
Print the answer modulo .
Hint
Clarification of the first example:
All possible sequences are: (0, 3, 4), (2, 3, 4), (0, 4, 3), (1, 4, 3), (4, 3, 0), (4, 3, 2), (3, 4, 0), (3, 4, 1).
Clarification of the second example:
One of the possible sequences is (0, 3, 2, 0, 0). Donald can achieve it by putting the first cube on the second place, the second cube on the third place, and the third cube on the second place, on top of the first cube.