CF1580A Portal
Description
CQXYM found a rectangle $ A $ of size $ n \times m $ . There are $ n $ rows and $ m $ columns of blocks. Each block of the rectangle is an obsidian block or empty. CQXYM can change an obsidian block to an empty block or an empty block to an obsidian block in one operation.
A rectangle $ M $ size of $ a \times b $ is called a portal if and only if it satisfies the following conditions:
- $ a \geq 5,b \geq 4 $ .
- For all $ 1 < x < a $ , blocks $ M_{x,1} $ and $ M_{x,b} $ are obsidian blocks.
- For all $ 1 < x < b $ , blocks $ M_{1,x} $ and $ M_{a,x} $ are obsidian blocks.
- For all $ 1
Input Format
The first line contains an integer $ t $ ( $ t \geq 1 $ ), which is the number of test cases.
For each test case, the first line contains two integers $ n $ and $ m $ ( $ 5 \le n \le 400 $ , $ 4 \le m \le 400 $ ).
Then $ n $ lines follow, each line contains $ m $ characters $ 0 $ or $ 1 $ . If the $ j $ -th character of $ i $ -th line is $ 0 $ , block $ A_{i,j} $ is an empty block. Otherwise, block $ A_{i,j} $ is an obsidian block.
It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 400 $ .
It is guaranteed that the sum of $ m $ over all test cases does not exceed $ 400 $ .
Output Format
Output $ t $ answers, and each answer in a line.
Explanation/Hint
In the first test case, the final portal is like this:
```
1110
1001
1001
1001
0111
```