29. Find all prime numbers $p$ such that there exist $m, n \in \mathbf{N}^{*}$, satisfying: $p=m^{2}+n^{2}$, and $p \mid\left(m^{3}+n^{3}-4\right)$.
29. From the given conditions, we know that \( p \mid (2m^3 + 2n^3 - 8) \), and \( p = m^2 + n^2 \), thus,
\[ p \mid (2m^3 + 2n^3 - 8 - 3(m^2 + n^2)(m + n)) \]

which means \( p \mid (-(m+n)^3 - 8) \). Therefore,
\[ p \mid (m+n+2)((m+n)^2 - 2(m+n) + 4) \]

Since \( p \) is a prime, we have \( p \mid (m+n+2) \) or \( p \mid ((m+n)^2 - 2(m+n) + 4) \).

If \( p \mid (m+n+2) \), then \( m^2 + n^2 \leq m + n + 2 \). Without loss of generality, assume \( m \leq n \). If \( m \geq 2 \), then \( m^2 - m \geq 2 \) and \( n^2 - n \geq 2 \), leading to \( m^2 + n^2 \geq m + n + 4 \), which is a contradiction. Therefore, \( m = 1 \), and thus \( n^2 \leq n + 2 \), giving \( n = 1 \) or 2. Hence, \( p = 2 \) or 5, and the corresponding pairs \((m, n) = (1,1)\) or \((m, n) = (1,2), (2,1)\) satisfy the conditions.

If \( p \mid ((m+n)^2 - 2(m+n) + 4) \), without loss of generality, assume \( p > 2 \) (otherwise, it falls into the previous discussion). In this case, \( p \mid (m^2 + n^2 + 2(mn - m - n + 2)) \). Combining \( p = m^2 + n^2 \) and \( p > 2 \), we get \( p \mid (mn - m - n + 2) \). However, at this point,
\[ 0 < (m-1)(n-1) + 1 = mn - m - n + 2 < mn \leq \frac{m^2 + n^2}{2} < p \]

which is a contradiction.
In summary, the required \( p = 2 \) or 5.