Rudolf and Snowflakes (hard version)

Problem Name:
Rudolf and Snowflakes (hard version)
Site:CodeForces
Links:
Tags:
Problem setters: