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 = '# cook your dish here\nfrom sys import stdin,stdout\nimport sys\nfrom bisect import bisect_left,bisect_right\n\n# stdin = open("input.txt", "r");\n# stdout = open("output.txt", "w");\n\nt= int(stdin.readline().strip())\n\nfor _ in range(t):\n\tn,m=stdin.readline().strip().split(\' \')\n\tn,m=int(n),int(m)\n\tarr=[]\n\tfor i in range(n):\n\t\tarr.append(list(map(int,stdin.readline().strip().split(\' \'))))\n\tctr=0\n\tvisited=[[False for i in range(m)] for j in range(n)]\n\tsol=[[1 for i in range(m)] for j in range(n)]\n\tpq=[]\n\tfor i in range(n):\n\t\tfor j in range(m):\n\t\t\tpq.append((arr[i][j],i,j))\n\tpq=sorted(pq,key=lambda e:(e[0]),reverse=True)\n\t# print(pq)\n\tfor i in pq:\n\t\tcv,yo,xo=i\n\t\tif visited[yo][xo]:\n\t\t\tcontinue\n\t\telse:\n\t\t\tstack=[xo,yo]\n\t\t\twhile len(stack):\n\t\t\t\ty=stack.pop(-1)\n\t\t\t\tx=stack.pop(-1)\n\t\t\t\tvisited[y][x]=True\n\t\t\t\tctr+=1\n\t\t\t\tsol[y][x]=0\n\t\t\t\tif x-1>=0 and x-1<m and y+1>=0 and y+1<n:\n\t\t\t\t\tif not visited[y+1][x-1]:\n\t\t\t\t\t\tstack.append(x-1)\n\t\t\t\t\t\tstack.append(y+1)\n\t\t\t\tif x>=0 and x<m and y+1>=0 and y+1<n:\n\t\t\t\t\tif not visited[y+1][x]:\n\t\t\t\t\t\tstack.append(x)\n\t\t\t\t\t\tstack.append(y+1)\n\t\t\t\tif x+1>=0 and x+1<m and y+1>=0 and y+1<n:\n\t\t\t\t\tif not visited[y+1][x+1]:\n\t\t\t\t\t\tstack.append(x+1)\n\t\t\t\t\t\tstack.append(y+1)\n\t\t\tsol[yo][xo]=1\n\n\tfor i in sol:\n\t\tfor j in i:\n\t\t\tstdout.write(str(j))\n\t\tstdout.write("\\n")'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14591