AT_arc203_e [ARC203E] Tile Grid with One Hole

Description

There is a grid with $ H $ rows and $ W $ columns, where the cell at the $ i $ -th row from the top and $ j $ -th column from the left is denoted as $ (i,j) $ . The grid has a hole only in cell $ (r,c) $ . We will tile all cells without a hole using several tiles. You are given non-negative integers $ N $ and $ M $ such that $ H \times W=L \times (N+M)+1 $ . A tile of $ 1 $ row and $ L $ columns is called a horizontal tile, and a tile of $ L $ rows and $ 1 $ column is called a vertical tile. Determine whether there exists a way to tile using exactly $ N $ horizontal tiles and $ M $ vertical tiles without rotation, and also show one such way if it exists. For details on the output format and more precise conditions, check the output section. Solve $ T $ test cases for each input file.

Input Format

The input is given from Standard Input in the following format: > $ T $ $ case_1 $ $ case_2 $ $ \vdots $ $ case_T $ Each case is given in the following format: > $ H $ $ W $ $ L $ $ N $ $ M $ $ r $ $ c $

Output Format

Output the answers in the following format: > $ output_1 $ $ output_2 $ $ \vdots $ $ output_T $ Here, $ output_t $ represents the output for the $ t $ -th test case. For each case, if it is possible to tile satisfying the conditions, let $ (A_i,B_i) $ be the leftmost cell covered by the $ i $ -th horizontal tile and $ (C_j,D_j) $ be the topmost cell covered by the $ j $ -th vertical tile, and output in the following format: > Yes $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ $ \vdots $ $ A_N $ $ B_N $ $ C_1 $ $ D_1 $ $ C_2 $ $ D_2 $ $ \vdots $ $ C_M $ $ D_M $ More precisely, output integer sequences $ A=(A_1,A_2,\dots,A_N),B=(B_1,B_2,\dots,B_N) $ of length $ N $ and $ C=(C_1,C_2,\dots,C_M),D=(D_1,D_2,\dots,D_M) $ of length $ M $ that satisfy all of the following conditions: - The union of $ \{(A_i,B_i+l)\mid i=1,2,\dots,N,\;l=0,1,\dots,L-1\} $ , $ \{(C_j+l,D_j)\mid j=1,2,\dots,M,\;l=0,1,\dots,L-1\} $ , and $ \{(r,c)\} $ equals $ \{(h,w)\mid h=1,2,\dots,H,\;w=1,2,\dots,W\} $ . Note that due to the constraint $ H \times W=L \times (N+M)+1 $ , when this condition holds, tiles do not overlap with each other. If it is impossible to satisfy the conditions, output `No`.

Explanation/Hint

### Sample Explanation 1 In the third test case, there is a hole in the top-left cell. It can be tiled as follows: ``` ┌─┬─┐ ┌─┤ │ │ │ ├─┴─┤ └─┴───┘ ``` ### Constraints - $ 1 \leq T \leq 5 $ - $ 1 \leq H \leq 1000 $ - $ 1 \leq W \leq 1000 $ - $ 2 \leq H \times W $ - $ 2 \leq L \leq 1000 $ - $ 0 \leq N $ - $ 0 \leq M $ - $ 1 \leq r \leq H $ - $ 1 \leq c \leq W $ - $ H \times W=L \times (N+M)+1 $ - The sum of $ N+M $ over all test cases is at most $ 6\times 10^5 $ . - All input values are integers.