Viterbi implemented in ML.