Lets Play the Hat?

Problem Name:
Lets Play the Hat?
Site:CodeForces
Links:
Tags:
Problem setters: