Score : $1200$ points
Given is a positive integer $N$. Find the number of permutations $(P_1,P_2,\cdots,P_{3N})$ of $(1,2,\cdots,3N)$ that can be generated through the procedure below. This number can be enormous, so print it modulo a prime number $M$.
Input is given from Standard Input in the following format:
$N$ $M$
Print the number of permutations modulo $M$.
1 998244353
6
All permutations of length $3$ count.
2 998244353
261
314 1000000007
182908545