409579: GYM103637 G Geometric shapes

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

G. Geometric shapestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

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.

Input

The 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$$$$$$

Output

For 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.

ExampleInput
2
3 3 2 2
4 4 1 2
Output
YES
1 1 1
1 0 2
2 2 2
NO

加入题单

上一题 下一题 算法标签: