INfinite loop--grid

hello i tried the question grid01 from infinite loop.But i got wrong anser everytime.Can you please help?
solution