apple pie's submission of Sarthak and his Magic Grid | CodeChef