Product Oriented Recurrence

CodeForces - 1182E