Catalan numbers#9643

Catalan numbers

1 second
128 megabytes
Easy

Catalan numbers c_n are defined by the recurrence relation:

c_0 = 1, \\ c_n = \sum_{k=0}^{n-1} c_k c_{n-k-1},\quad n > 0

Compute the -th Catalan number modulo .

Input

Two integers n~(0 \le n \le 10^4) and m~(0 < m \le 10^9).

Output

Print the value of c_n \bmod m.

Examples

Example 1

Loading
Loading