UVA785 Grid Colouring

Description

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=9&page=show_problem&problem=726 [PDF](https://uva.onlinejudge.org/external/7/p785.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA785/a5984ffeb3f7b44194af44fe96606244099f9f08.png)

Input Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA785/932f72d73350e340df9d488dda6a2dc49a57d630.png)

Output Format

![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA785/d695e7c504d7c57288d87a1d47fab4cee6f00be6.png)