#FLWRS. Flowers
Flowers
Hanadi has N flower pots each with a unique flower. The pots are arranged along in a line.
One day, She decided to change their order under the condition that no two pots that were originally next to each other remain next to each other.
Task
Write a program that is given the number of pots, calculates the number of possible orders satisfying the condition modulo a given integer M.
Input
- Line 1 contains the integer N, the number of flower pots.
- Line 2 contains the integer M.
Output
A single line containing one integer between 0 and M-1 (inclusive): the number of possible orders modulo M.
Constraints
1 ≤ N ≤ 2,000
2 ≤ M ≤ 1,000,000,000
Number of test cases is 28.
Example
Input: 5 11</p>Output: 3
Explanation
For 5 pots, there are 14 orders satisfying Hanadi's condition, assuming the original order of pots was "ABCDE", then the 14 possible orders are:- ACEBD
- ADBEC
- BDACE
- BDAEC
- BECAD
- CADBE
- CAEBD
- CEADB
- CEBDA
- DACEB
- DBEAC
- DBECA
- EBDAC
- ECADB
14 modulo 11 = 3, so the answer is 3.