Let the common difference and common ratio of the arithmetic and geometric sequences be $d, q$, respectively, then $a_{5}=-1+2 d, a_{6}=-1+3 d$ $\Rightarrow(-1+3 d)^{2}=4(-1+2 d) \Rightarrow 9 d^{2}-14 d+5=0 \Rightarrow d=\frac{5}{9}$ (discard) or $d=1$.
Thus, $d=1 \Rightarrow a_{n}=\left\{\begin{array}{l}n-4, n \leqslant 6, n \in \mathbf{N}^{*}, \\ 2^{n-5}, n>6, n \in \mathbf{N}^{*} .\end{array}\right.$
When $m \leqslant 4$, then $m-4+m-3+m-2=3(m-3)=(m-4)(m-3)(m-2)$ $\Rightarrow m=3$ or $(m-4)(m-2)=3 \Rightarrow m=1$;
When $m \geqslant 5$, then $2^{m-5}+2^{m-4}+2^{m-3}=7 \cdot 2^{m-5}=2^{m-5} \cdot 2^{m-4} \cdot 2^{m-3} \Rightarrow 2^{2 m-7}=7$, no solution. In summary, $m=1$ or 3.
5. Given an integer sequence $\left\{a_{n}\right\}$ that satisfies $a_{3}=-1, a_{7}=4$, the first 6 terms form an arithmetic sequence, and from the 5th term onwards, they form a geometric sequence. If a positive integer $m$ makes $a_{m}+a_{m+1}+a_{m+2}=a_{m} a_{m+1} a_{m+2}$, then $m=$ $\qquad$ .