8. Given a sequence $\left\{a_{n}\right\}$ with 9 terms, where $a_{1}=a_{9}=1$, and for each $i \in\{1,2, \cdots, 8\}$, we have $\frac{a_{i+1}}{a_{i}} \in\left\{2,1,-\frac{1}{2}\right\}$, then the number of such sequences is $\qquad$
According to the problem, $\frac{a_{2}}{a_{1}} \cdot \frac{a_{3}}{a_{2}} \cdots \frac{a_{9}}{a_{8}}=1$, and $\frac{a_{i+1}}{a_{i}} \in\left\{2,1,-\frac{1}{2}\right\}, i \in\{1,2, \cdots, 8\}$, thus $\frac{a_{i+1}}{a_{i}}(i=1,2, \cdots, 8)$ where $-\frac{1}{2}$ appears an even number of times.
Therefore, when $\frac{a_{i+1}}{a_{i}}=-\frac{1}{2}(i=1,2, \cdots, 8)$ appears 0 times, there is 1 corresponding sequence; when $\frac{a_{i+1}}{a_{i}}=-\frac{1}{2}(i=1,2, \cdots, 8)$ appears 2 times, there are $C_{8}^{2} \cdot C_{6}^{2}$ corresponding sequences; when $\frac{a_{i+1}}{a_{i}}=-\frac{1}{2}(i=1,2, \cdots, 8)$ appears 4 times, there are $C_{8}^{4}$ corresponding sequences. Therefore, the number of such sequences is $1+C_{8}^{2} \cdot C_{6}^{2}+C_{8}^{4}=491$.