A wonderful problem that covers almost all topics
I've never seen such an educational problem like 1287C - Garland before.
UPD: Fixed now.