Optimal detection of a change in distribution when the observations form a Markov chain with a finite state space