#include int main () { int n = 0; long long m = 0LL; int res = 0; long long ans = 1LL; int acc[10000000][3][3] = {}; res = scanf("%d", &n); res = scanf("%lld", &m); acc[0][0][0] = 1; acc[0][0][1] = 2; acc[0][0][2] = 0; acc[0][1][0] = 1; acc[0][1][1] = 1; acc[0][1][2] = 2; acc[0][2][0] = 1; acc[0][2][1] = 1; acc[0][2][2] = 1; for (int i = 1; i < 2*n; i++) { long long tmp1[3][3] = { { 1LL, (long long)(i+2), 0LL }, { 1LL, 1LL, (long long)(i+2) }, { 1LL, 1LL, 1LL} }; long long tmp2[3][3] = {}; for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { for (int l = 0; l < 3; l++) { tmp2[j][k] += tmp1[j][l]*((long long)acc[i-1][l][k]); } acc[i][j][k] = (int)(tmp2[j][k]%m); } } } for (int i = 0; i < 2*n-1; i++) { ans *= (long long)(i+1); ans %= m; } for (int i = 2; i < n; i++) { long long mul = 0LL; for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { mul += (long long)acc[2*(i-2)][j][k]; } } ans *= mul%m; ans %= m; } printf("%lld\n", ans%m); return 0; }