Monk is standing at the door of his classroom. There are currently N students in the class, i’th student got Aicandies.There are still M more students to come. At every…