n,m = map(int,input().split()) x = 1; dp = [0]*8+[1] for i in range(1,2*n): x = x*i%m for i in range(2,2*n-1): eq = [0]*9 for j in range(3): for k in range(3): for l in range(3): if k==2 and l==0: continue if j!=2 and k!=1 and l!=0: eq[3*k+l] += dp[3*j+k]*(i-2) else: eq[3*k+l] += dp[3*j+k] dp = [v%m for v in eq] if i%2==0: x = x*(dp[0]+dp[1]+dp[3]+dp[4]+dp[6]+dp[7])%m print(x)