Painter Problem

Unable to pass the 2 test case please help
my code

I have edited your code… Try to submit it now…

What was the mistake in my logic?
please tell.

Your code is not producing any output