Link for CHEFMAST from LOCJUL17

Can anyone provide link for CHEFMAST question which had been removed from LOCJUL17. I have tried to figure out the logic during the contest but unable to do. I would appreciate if any member of community help me with the logic behind that question. Thanks in advance.

That was done because of this report… Similar problem can be found on codeforces here… with editorial and solutions…

Thanks man