Fixing up a word with condition. Please help me solve the next question.

How many words can you fix from $\{0,1,2, ..., m-1\}$ in length $n$, when the number of zeros in the word is odd?
Examples for valid words: $001, 00, 00m-1, 002$ and so on.

Thanks in advance.
 A: Let $a_n$ be the number of words of length $n$ with an even number of $0$'s, and $b_n$ the number with an odd number of $0$'s. We have the following recurrences:
$$a_{n+1}=(m-1)a_n+b_n;\qquad b_{n+1}=a_n+(m-1)b_n.$$
For to make a word of length $n+1$ with an even number of $0$'s, we either append one of $1,2,\dots, m-1$ to an $n$-letter word with an even number of $0$'s, or append $0$ to an $n$-letter word with an odd number of $0$'s.  The argument for the second recurrence is almost the same.
There are ,many ways to solve the above system. One simple way that takes advantage of the symmetry is to subtract. We get
$$a_{n+1}-b_{n+1}=(m-2)(a_n-b_n).\tag{1}$$
We have $a_0=1$ (the empty word) and $b_0=0$. Or, for people who don't like the empty word,  we have $a_1=m-2$ amd $b_1=1$.  Thus from (1) we get
$$a_n-b_n=(m-2)^n.\tag{2}$$
The total number of words of length $n$ is $m^n$, and therefore
$$a_n+b_n=m^n.\tag{3}$$
Equations (2) and (3) are linear equations in the two "unknowns" $a_n$ and $b_n$. Solve.
