Markov Algorithm