#Q241. 「一本通 6.6 练习 10」有趣的数列

「一本通 6.6 练习 10」有趣的数列

Description

We call a sequence of length 2n2n interesting if and only if it satisfies the following three conditions:

  1. It is a permutation {ai}\{a_i\} of the 2n2n integers from 11 to 2n2n;
  2. All odd-indexed terms satisfy a1<a3<<a2n1a_1\lt a_3\lt \cdots \lt a_{2n-1}, and all even-indexed terms satisfy a2<a4<<a2na_2\lt a_4\lt \cdots \lt a_{2n};
  3. Any two adjacent terms a2i1a_{2i-1} and a2i(1in)a_{2i}(1\le i\le n) satisfy that the odd-indexed term is less than the even-indexed term, i.e., a2i1<a2ia_{2i-1}\lt a_{2i}.

The task is: For a given nn, determine how many different interesting sequences of length 2n2n exist. Since the final answer may be very large, only output the answer modulo PP.

Input Format

The input contains only two integers nn and PP separated by a space.

Output Format

Output a single integer, representing the number of different interesting sequences of length 2n2n modulo PP.

Sample 1

The corresponding 55 interesting sequences are $\{1,2,3,4,5,6\},\{1,2,3,5,4,6\},\{1,3,2,4,5,6\},\{1,3,2,5,4,6\},\{1,4,2,5,3,6\}$.

3 10

5

Data Range and Hints

For 50%50\% of the data, n1000,P106n\le 1000,P\le 10^6;
For all data, 1n106,2P1091\le n\le 10^6,2\le P\le 10^9.