Extending the Viterbi algorithm to return Top-k state sequences