Let f(n) be the number of ways to color a cycle graph of n nodes using k colors.
Suppose if we have only 2 nodes and k colors, f(2) = k*(k-1)
Similarly, f(3) = k(k-1)(k-2).
Now lets find the recurrence relation for f(n).
First node can be colored in k ways.
Second node can be colored in (k-1) ways.
Similarly third, fourth,..., last node can be colored in (k-1) ways.
So
But the last and first nodes can be the same color, we need to remove those arrangements.
Now merge the first node and last node as one node.
Now the number of ways to color (n-1) nodes using k colors is f(n-1)
So the recurrence relation is
When n is even,
a = k-1, r = -(k-1)
When n is odd,
a = -(k-1), r = -(k-1)
Coming to our problem, n = 8 and k = 10.
$$f(8) = 9*(9^7+1)=43046730$$