Bessies Birthday Cake (Hard Version)

Problem Name:
Bessies Birthday Cake (Hard Version)
Site:CodeForces
Links:
Tags:
Problem setters: