Determine all natural numbers $m, n$ and all prime numbers $p$ such that

$$
m\left(4 m^{2}+m+12\right)=3\left(p^{n}-1\right)
$$
We rewrite the equation in the form

$$
3 p^{n}=4 m^{3}+m^{2}+12 m+3=(4 m+1)\left(m^{2}+3\right)
$$

From this, we deduce that there exist natural numbers $u, v, a, b$ such that $4 m+1=3^{u} p^{a}$ and $m^{2}+3=3^{v} p^{b}$ with $u+v=1$ and $a+b=n$.
If $m=0$, the equation becomes $3 p^{n}=3$, so $n=0$ and any prime number works.
Now suppose $m \geqslant 1$. Then $4 m+1>3$ and $m^{2}+3>3$, so $a \geqslant 1$ and $b \geqslant 1$.
We have

$$
\begin{aligned}
16 \times 3^{v} p^{b} & =16\left(m^{2}+3\right)=(4 m)^{2}+48=((4 m+1)-1)^{2}+48 \\
& =3^{2 u} p^{2 a}-2 \times 3^{u} p^{a}+49
\end{aligned}
$$

Since $p$ divides the left-hand side, it divides the right-hand side, so $p \mid 49$, which gives $p=7$. We then replace 49 with $p^{2}$:

$$
16 \times 3^{v} p^{b}=3^{2 u} p^{2 a}-2 \times 3^{u} p^{a}+p^{2}
$$

If $a=1$ then $4 m+1$ is 7 or 21. Since $m$ is an integer, we have $4 m+1=21$, or $m=5$, which implies $3^{v} p^{b}=m^{2}+3=28$. Impossible. Therefore, $a \geqslant 2$. We deduce that $3^{2 u} p^{2 a}-2 \times 3^{u} p^{a}+p^{2}$ is divisible by $p^{2}$, so $16 \times 3^{v} p^{b}$ is divisible by $p^{2}$, hence $b \geqslant 2$.
If $a \geqslant 3$, then $16 \times 3^{v} p^{b}=3^{2 u} p^{2 a}-2 \times 3^{u} p^{a}+p^{2}$ is congruent to $p^{2}$ modulo $p^{3}$, so it is not divisible by $p^{3}$, therefore $b=2$. By dividing by $p^{2}$, we get that $16 \times 3^{v} \equiv 1[p]$. For $v=0$ this gives $16 \equiv 1[7]$ and for $v=1$ this gives $48 \equiv 1[7]$. Impossible.
Therefore, we must have $a=2$ and $4 m+1=3^{u} \times 49$. If $u=0$ then $m=12$ and $n=4$. If $u=1$ then $4 m+1=147$, which is impossible.
Conclusion: the only solutions are

- $m=0, n=0, p$ any prime, and
- $m=12, n=4, p=7$.