Spinning Round (Hard Version)

Problem Name:
Spinning Round (Hard Version)
Site:CodeForces
Links:
Tags:
Problem setters: