Bayes algorithm begin