8. Let $n$ be a positive integer, and let $f(n)$ denote the number of $n$-digit numbers (called wave numbers) $\overline{a_{1} a_{2} \cdots a_{n}}$ that satisfy the following conditions:
(i) Each digit $a_{i} \in\{1,2,3,4\}$, and $a_{i} \neq$ $a_{i+1}(i=1,2, \cdots)$;
(ii) When $n \geqslant 3$, the signs of $a_{i}-a_{i+1}$ and $a_{i+1}-a_{i+2}$ $(i=1,2, \cdots)$ are opposite.
(1) Find the value of $f(10)$;
(2) Determine the remainder when $f(2008)$ is divided by 13.
And the $n$-digit waveform number $\overline{a_{1} a_{2} \cdots a_{n}}$ that satisfies $a_{1}>a_{2}$ is called a "B-type number". According to symmetry, when $n \geqslant 2$, the number of B-type numbers is also $g(n)$. Therefore, $f(n)=2 g(n)$.

Next, we find $g(n)$: Let $m_{k}(i)$ represent the number of $k$-digit A-type waveform numbers with the last digit being $i$ $(i=1,2,3,4)$. Then $g(n)=\sum_{i=1}^{4} m_{n}(i)$. Since $a_{2 k-1}a_{2 k+1}$, then 1) when $k$ is even,
$m_{k+1}(4)=0, m_{k+1}(3)=m_{k}(4)$,
$m_{k+1}(2)=m_{k}(4)+m_{k}(3)$,
$m_{k+1}(1)=m_{k}(4)+m_{k}(3)+m_{k}(2)$.
2) When $k$ is odd,
$m_{k+1}(1)=0, m_{k+1}(2)=m_{k}(1)$,
$m_{k+1}(3)=m_{k}(1)+m_{k}(2)$,
$m_{k+1}(4)=m_{k}(1)+m_{k}(2)+m_{k}(3)$. (2)
It is easy to see that $m_{2}(1)=0, m_{2}(2)=1, m_{2}(3)=2$, $m_{2}(4)=3$, then $g(2)=6$. Therefore,
$$
\begin{array}{l}
m_{3}(1)=m_{2}(2)+m_{2}(3)+m_{2}(4)=6, \\
m_{3}(2)=m_{2}(3)+m_{2}(4)=5, \\
m_{3}(3)=m_{2}(4)=3, \\
m_{3}(4)=0 .
\end{array}
$$

So, $g(3)=\sum_{i=1}^{4} m_{3}(i)=14$.
And by $m_{4}(1)=0, m_{4}(2)=m_{3}(1)=6$,
$m_{4}(3)=m_{3}(1)+m_{3}(2)=11$,
$$
m_{4}(4)=m_{3}(1)+m_{3}(2)+m_{3}(3)=14,
$$

So, $g(4)=\sum_{i=1}^{4} m_{4}(i)=31$.
Similarly, we get
$g(5)=70, g(6)=157, g(7)=353$,
$g(8)=793, \cdots$.
Generally, when $n \geqslant 5$,
$g(n)=2 g(n-1)+g(n-2)-g(n-3)$.
Now we prove formula (3). By induction on $n$.
When $n=5,6,7,8$, it has been verified.
Assume formula (3) holds up to $n$. Consider the case for $n+1$.
When $n$ is even, according to 1) and 2), we have
$m_{n+1}(4)=0$,
$m_{n+1}(3)=m_{n}(4)$,
$m_{n+1}(2)=m_{n}(4)+m_{n}(3)$,
$m_{n+1}(1)=m_{n}(4)+m_{n}(3)+m_{n}(2)$.
And $m_{n}(1)=0$, then
$g(n+1)=\sum_{i=1}^{4} m_{n+1}(i)$
$=2\left(\sum_{i=1}^{4} m_{n}(i)\right)+m_{n}(4)-m_{n}(2)$
$=2 g(n)+m_{n}(4)-m_{n}(2)$.
Also, $m_{n}(4)$
$=m_{n-1}(1)+m_{n-1}(2)+m_{n-1}(3)+0$
$=\sum_{i=1}^{4} m_{n-1}(i)=g(n-1)$,
$m_{n}(2)=m_{n-1}(1)$
$=m_{n-2}(4)+m_{n-2}(3)+m_{n-2}(2)+0$
$=g(n-2)$,

At this point, we have
$g(n+1)=2 g(n)+g(n-1)-g(n-2)$.
When $n$ is odd, $g(n+1)=\sum_{i=1}^{4} m_{n+1}(i)$.
And $m_{n+1}(1)=0, m_{n+1}(2)=m_{n}(1)$,
$m_{n+1}(3)=m_{n}(1)+m_{n}(2)$,
$m_{n+1}(4)=m_{n}(1)+m_{n}(2)+m_{n}(3)$,

Then $g(n+1)=\sum_{i=1}^{4} m_{n+1}(i)$
$=2 \sum_{i=1}^{4} m_{n}(i)+m_{n}(1)-m_{n}(3)$
$=2 g(n)+m_{n}(1)-m_{n}(3)$.
Also, $m_{n}(1)$
$=m_{n-1}(4)+m_{n-1}(3)+m_{n-1}(2)+0$
$=g(n-1)$,
$m_{n}(3)=m_{n-1}(4)$
$=m_{n-2}(1)+m_{n-2}(2)+m_{n-2}(3)+0$
$=g(n-2)$,

At this point, we also have
$g(n+1)=2 g(n)+g(n-1)-g(n-2)$.
Therefore, by induction, for all $n \geqslant 5$, formula (3) holds.
According to formula (3),
$g(9)=2 g(8)+g(7)-g(6)=1782$,
$g(10)=2 g(9)+g(8)-g(7)=4004$,
So, $f(10)=2 g(10)=8008$.
Now consider the sequence $\{g(n) \mid$ modulo 13.
Using formula (3), it is easy to calculate that when $n=2,3, \cdots, 14,15$,
$16, \cdots$, the remainders of $g(n)$ when divided by 13 are:
$6,1,5,5,1,2,0,1,0,1,1,3 ; 6,1,5,5, \cdots$
Therefore, when $n \geqslant 2$, the sequence of remainders of $\{g(n)\}$ when divided by 13 is a periodic sequence, with the smallest period being 12.
Since $2008=12 \times 167+4$, then
$g(2008) \equiv 5(\bmod 13)$.
Therefore, $f(2008) \equiv 10(\bmod 13)$.