munte

Time limit: 0.5s Memory limit: 128MB Input: Output:

Task

A permutation of order NN is called a mountain permutation if and only if for every ii, 1iN1 \leq i \leq N, with ii even, the condition v[i1]>v[i]<v[i+1]v[i-1]>v[i]<v[i+1] holds. If i=Ni=N, only the condition v[i1]>v[i]v[i-1]>v[i] needs to hold.

For example, the permutation of order 5 [2,1,4,3,5][2, 1, 4, 3, 5] is a mountain permutation because 2>1<42>1<4 and 4>3<54>3<5, but the permutation of order 5 [2,1,5,4,3][2, 1, 5, 4, 3] is not a mountain permutation because 5>4>35>4>3, so for i=4i=4 the condition is not satisfied.

A permutation of order NN is a sequence of NN elements that contains all elements from 11 to NN in any order. For example, the sequence [1,4,5,2,3][1, 4, 5, 2, 3] is a permutation of order 55, but the sequences [1,3,2,3,5][1, 3, 2, 3, 5] and [1,2,3,5,6][1, 2, 3, 5, 6] are not permutations of order 55.

Given a number NN, find the number of mountain permutations of order ii, 1iN1 \leq i \leq N. Since the answer can be very large, only the remainder of the answer divided by another given number MM is requested.

Input data

The first line contains the natural numbers NN, representing the order number for which you need to find the permutations, and MM, the modulo for the answer.

Output data

The first line contains the result modulo MM.

Constraints and clarifications

  • 1N50001 \leq N \leq 5000
  • 1M1091 \leq M \leq 10^9
  • MM is prime
  • M>NM > N
# Points Constraints
1 11 1N101 \leq N \leq 10
2 13 1N181 \leq N \leq 18
3 17 1N5001 \leq N \leq 500
4 59 No additional constraints

Example

stdin

5 19

stdout

6

Explanation

The number of mountain permutations of order 5\leq 5 is 2525. Two of these permutations are [4,1,3,2][4, 1, 3, 2] and [3,1,2][3, 1, 2].

Log in or sign up to be able to send submissions!