#include #include #include using namespace std; int main() { int N; cin >> N; long long mod; cin>>mod; vector> dp(2 * N, vector(3, 0)); vector> score(2 * N, vector(3, 0)); dp[1][2] = 1; score[1][2] = 1; for (int i = 1; i < 2 * N - 1; ++i) { for (int j = 0; j < 3; ++j) { for (int k = 0; k < 3; ++k) { if (j == 2 && k == 0) { continue; } dp[i + 1][k] += dp[i][j]; dp[i + 1][k] %= mod; if (k <= j) { score[i + 1][k] += score[i][j]; } else if (k == 1 && j == 0) { score[i + 1][k] += score[i][j] * (i - 1); } else if (k == 2 && j == 1) { score[i + 1][k] += score[i][j] * i; } else { long long w = score[i][j] * i; w %= mod; w *= i - 1; w %= mod; score[i + 1][k] += w; } score[i + 1][k] %= mod; } } } long long result = 1; for (int x = 1; x < 2 * N; ++x) { result *= x; result %= mod; } for (int i = 1; i < N; ++i) { result *= score[2 * i + 1][0]; result %= mod; } cout << result << endl; return 0; }