There is a building with $N$ floors (numbered $1$ through $N$ from bottom to top); on each floor, there are $M$ windows (numbered $1$ through $M$ from left to right). Let's denote the $j$-th window on the $i$-th floor by $(i, j)$.
All windows in the building need to be cleaned one by one in a specific order. You are given this order as a matrix $A$ with $N$ rows and $M$ columns; for each valid $i$ and $j$, the window $(i, j)$ must be cleaned on the $A_{N-i+1,j}$-th turn. 
Whenever we clean a window $(i, j)$, it becomes clean, but the dirty water used for cleaning it flows down to windows $(i-1, j-1)$, $(i-1, j)$ and $(i-1, j+1)$ (more precisely, to all of these windows which exist), so these windows become dirty again. Then, the water flows further down, so the same applies for other windows below: whenever a window $(i, j)$ becomes dirty, windows $(i-1, j-1)$, $(i-1, j)$ and $(i-1, j+1)$ become dirty as well. For example, cleaning a window $(5, 3)$ will make the window $(3, 2)$ dirty. The next window is cleaned only after water flows down completely. Note that each window is cleaned only once and there may be dirty windows at the end.
For each window, determine whether it will be clean after the cleaning process ends.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains two space-separated integers $N$ and $M$. 
- $N$ lines follow. For each $i$ ($1 \le i \le N$), the $i$-th of these lines contains $M$ space-separated integers $A_{i, 1}, A_{i, 2}, \ldots, A_{i, M}$.

-----Output-----
For each test case, print $N$ lines; each of them should contain a string with length $M$. For each valid $i$ and $j$, the $j$-th character on the $i$-th line should be '1' if the window $(N-i+1, j)$ is clean or '0' if it is dirty.

-----Constraints-----
- $1 \le T \le 1,000$
- $1 \le N, M \le 10^3$
- $1 \le A_{i, j} \le N \cdot M$ for each valid $i, j$
- the elements of the matrix $A$ are pairwise distinct
- the sum of $N \cdot M$ over all test cases does not exceed $10^6$

-----Subtasks-----
Subtask #1 (50 points):
- $N, M \le 25$
- the sum of $N \cdot M$ over all test cases does not exceed $625$
Subtask #2 (50 points): original constraints

-----Example Input-----
1
3 4
1 3 7 10
9 2 4 11
8 12 5 6 

-----Example Output-----
1111
1001
0100

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'def arr_str(arr):\r\n\tstrr=""\r\n\tfor i in arr:\r\n\t\tstrr+=str(i)\r\n\treturn(strr)\r\nfor _ in range(int(input())):\r\n\tn,m=map(int,input().split())\r\n\tA=[0]*n\r\n\tfor i in range(n):\r\n\t\ttemp=[0]\r\n\t\tB=[int(i) for i in input().split()]\r\n\t\ttemp.extend(B)\r\n\t\ttemp.append(0)\r\n\t\tA[i]=temp\r\n\r\n\t# print(A)\r\n\tans=[[0 for i in range(m)] for j in range(n)]\r\n\tdp=[[0 for i in range(m+2)] for j in range(n)]\r\n\tfor i in range(m):\r\n\t\tdp[0][i+1]=A[0][i+1]\r\n\tfor i in range(1,n):\r\n\t\tfor j in range(1,m+1):\r\n\t\t\ttemp=max(dp[i-1][j-1],dp[i-1][j],dp[i-1][j+1])\r\n\t\t\t# print(temp)\r\n\t\t\tif(temp>A[i][j]):\r\n\t\t\t\tans[i-1][j-1]=0\r\n\t\t\telse:\r\n\t\t\t\tans[i-1][j-1]=1\r\n\t\t\ttemp=max(temp,A[i][j])\r\n\t\t\tdp[i][j]=temp\r\n\ttem=[1]*m\r\n\t\r\n\tprint(arr_str(tem),end="\\n")\r\n\tfor i in range(n-1):\r\n\t\tprint(arr_str(ans[i]),end="\\n")\r\n\r\n\t'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13963