409579: GYM103637 G Geometric shapes
Description
You have to tile all cells of the grid $$$n \times m$$$ with shapes from tetris (tetromino) except for one cell with coordinates $$$(r, c)$$$.
There are the following tetromino shapes:
And also their turns and reflections.
InputThe first line contains a single integer $$$t$$$ — the number of testcases. The following $$$t$$$ lines contain four space-separated integers $$$n_i$$$ $$$m_i$$$ $$$r_i$$$ $$$c_i$$$, denoting the size of the grid and coordinates of the cell, which you don't have to tile, respectively.
$$$$$$ 1 \le r_i \le n_i $$$$$$ $$$$$$ 1 \le c_i \le m_i $$$$$$ $$$$$$\sum n_i * m_i \le 10^5$$$$$$
OutputFor each test case print "YES" if tiling is possible. Next, print $$$n_i \times m_i$$$ numbers denoting the tiling. Each of the numbers correspond to the number of the figure to which the cell belongs. The cell $$$(r_i, c_i)$$$ has to contain 0, and the remaining figures should be numbered sequentially starting with 1. If tiling is impossible, then print "NO" in a single line.
ExampleInput2 3 3 2 2 4 4 1 2Output
YES 1 1 1 1 0 2 2 2 2 NO