Strange Grid

my solution : CodeChef: Practical coding for everyone
what is wrong , I can’ figure out
Thanks in advance