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 = "t = int(input())\r\nfor i in range(t):\r\n\tn, m = map(int, input().split())\r\n\tarr = []\r\n\tfor j in range(n):\r\n\t\tarr += [[int(j) for j in input().split()]]\r\n\t# print(arr)\r\n\r\n\tdp = [[0 for i in range(m)] for j in range(n)]\r\n\tans = [[0 for i in range(m)] for j in range(n)]\r\n\r\n\tfor i in range(m):\r\n\t\tdp[0][i] = arr[0][i]\r\n\t\tans[0][i] = 1\r\n\r\n\tif m == 1:\r\n\t\tfor i in range(1, n):\r\n\t\t\tdp[i][0] = max(dp[i-1][0], arr[i][0])\r\n\t\t\tif dp[i][0] == arr[i][0]:\r\n\t\t\t\tans[i][0] = 1\r\n\t\t# print(dp)\r\n\t\tfor x in ans:\r\n\t\t\tprint(*x, sep='')\r\n\t\tcontinue\r\n\r\n\tfor i in range(1, n):\r\n\t\tdp[i][0] = max(dp[i-1][0], dp[i-1][1], arr[i][0])\r\n\t\tif dp[i][0] == arr[i][0]:\r\n\t\t\tans[i][0] = 1\r\n\r\n\t\tfor j in range(1, m-1):\r\n\t\t\tdp[i][j] = max(dp[i-1][j], dp[i-1][j-1], dp[i-1][j+1], arr[i][j])\r\n\t\t\tif dp[i][j] == arr[i][j]:\r\n\t\t\t\tans[i][j] = 1\r\n\r\n\t\tdp[i][m-1] = max(dp[i-1][m-1], dp[i-1][m-2], arr[i][m-1])\r\n\t\tif dp[i][m-1] == arr[i][m-1]:\r\n\t\t\tans[i][m-1] = 1\r\n\r\n\tfor x in ans:\r\n\t\tprint(*x, sep='')\r\n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14265