#include long long solve_slow(int n, int m) { int i, j, cur, prev; long long tmp = 1, dp[2][3]; for (i = 3; i <= n; i++) { dp[0][0] = 1; dp[0][1] = 1; dp[0][2] = 1; for (j = 2, cur = 1, prev = 0; j <= (i - 2) * 2; j++, cur ^= 1, prev ^= 1) { dp[cur][0] = (dp[prev][0] + dp[prev][1] + dp[prev][2]) % m; dp[cur][1] = (dp[prev][0] * j + dp[prev][1] + dp[prev][2]) % m; dp[cur][2] = (dp[prev][1] * j + dp[prev][2]) % m; } tmp = tmp * (dp[prev][0] + dp[prev][1] + dp[prev][2]) % m; } for (i = 2; i <= n * 2 - 1; i++) tmp = tmp * i % m; return tmp; } int main() { int n, m; scanf("%d %d", &n, &m); if (n <= 20000) printf("%lld\n", solve_slow(n, m)); else return -1; fflush(stdout); return 0; }