2. (20 points) Consider ternary strings - that is, strings where 0, 1, 2 are the only symbols used. For $n \ge 1$, let $a_n$ count the number of ternary strings of length $n$ where substring 10 does not appear.
For example $a_1 = 3$ since in this case the string are 0, 1, 2. $a_2 = 8$ since in this case the string are
00, 01, 02, 11, 12, 20, 21, 22. $a_3 = 21$ since in this case the string are
000, 001, 002, 011, 012, 020, 021, 022, 111, 112, 120, 121, 122, 200, 201, 202, 211, 212, 220, 221, 222.
Find and solve a recurrence relation for $a_n$. Hint: Let $a_n^i$ be the number of ternary strings of
length $n$ satisfying the required property and last digit is $i$, for $i = 0, 1, 2$. Then $a_n = a_n^0 + a_n^1 + a_n^2$