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 = "import numpy as np\r\nfor _ in range(int(input())):\r\n\tn,m = map(int,input().split())\r\n\torder = np.zeros((n*m,2),dtype=np.uint8)\r\n\tstate = np.ones((n,m),dtype=np.uint8)*2\r\n\tfor i in range(n):\r\n\t\tj = 0\r\n\t\tfor e in map(int,input().split()):\r\n\t\t\torder[e-1] = i,j\r\n\t\t\tj+=1\r\n\r\n\tfor i0 in range(n*m-1,-1,-1):\r\n\t\ti,j = order[i0]\r\n\t\t# print(i,j)\r\n\t\tif state[i,j]==2:#same as init or not changed till now\r\n\t\t\t# print(i,j)\r\n\t\t\tj_start = j_end = j\r\n\t\t\tstate[i,j]=1#clean at the end\r\n\t\t\twhile i<n-1:\r\n\t\t\t\ti+=1\r\n\t\t\t\tj_start = max(0,j_start-1)\r\n\t\t\t\tj_end = min(m,j_end+1)\r\n\t\t\t\tstate[i,j_start:j_end+1] &= 1# if will be cleaned later not affected\r\n\t\t\t\t#if init or dirty marked as dirty set to 0\r\n\t\t\t\t# print(i,j_start,j_end)\r\n\t# print(order)\r\n\tfor i in range(n):\r\n\t\tprint(''.join(map(str,state[i])))"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 6171050