apple pie's submission of Construct N | CodeChef