An area named Renus, is divided into $(N \times M)$ cells. According to archaeological survey the area contains huge amount of treasure. Some cells out of $(N \times M)$ cells contain treasure. But problem is, you can't go to every cell as some of the cells are blocked.  
For every $a_{ij}$ cell($1 \leq i \leq N$,$1 \leq j \leq M$), your task is to find the distance of the nearest cell having treasure. 
Note:
- You can only traverse up, down, left and right from a given cell.
- Diagonal movements are not allowed.
- Cells having treasure can't be blocked, only empty cells ( cells without treasure) can be blocked.  

-----Input Format:------
- First line contains $T$, the number of test cases.
- Second line contains two space-separated integers $N\ and\ M$.
- Third line contains a single integer $X$ denoting number of cells having treasures, followed by $X$ lines containing two space-separated integers $x_i$ and $y_i$ denoting  position of row and column of $i^{th}$ treasure, for every $1\leq i \leq X$
- The next line contains a single integer $Y$ denoting the number of cells that are blocked, and it is followed by subsequent $Y$ lines containing  two space-separated integers $u_i$ and $v_i$ denoting position of row and column of blocked cells , for every $1\leq i \leq Y$

-----Constraints:------
- $1\le T \le 100$
- $1 \le N, M \le 200$
- $1 \le X < N*M$
- $0 \le Y <(N*M) - X$
- $1 \le x_i,u_j \le N, for\ every\ 1 \le i \le X\ and\ 1 \le j \le Y$
- $1 \le y_i,v_j \le M, for\ every\ 1 \le i \le X\ and\ 1 \le j \le Y$

-----Output Format:------
For each test case print a $N \times M$ matrix where each cell consists of distance of nearest treasure. Cells that are blocked will show "$X$" (without quotes). Also cells that doesn't have access to any treasure will show "$-1$" (without quotes).
Note: Co-ordinate of top left cell is $(1,1)$.

-----Sample Input-----
1
3 3
2
1 1
1 3
2
2 1
2 2

-----Sample Output-----
0 1 0 
X X 1
4 3 2

-----Explanation:-----
- Coordinates  (1,1) and (1,3)  shows "0" because they contain treasure and nearest distance is 0.
- Coordinates (2,1) and (2,2) shows "X" as they are blocked.
- Rest shows distance of nearest cell having treasure.

```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 sys\nimport numpy as np\nfrom collections import deque\n\nreadline = lambda : list(map(int, sys.stdin.readline().replace("\\n", "").split(" ")))\n\n(T,) = readline()\n\ndef run():\n N, M = readline()\n grid = np.full((N, M), -1)\n queue = deque()\n \n (X,) = readline()\n for _ in range(X):\n  (x, y) = readline()\n  (x, y) = (x-1, y-1)\n  queue.append((x, y))\n  grid[x, y] = 0\n \n (Y,) = readline()\n for _ in range(Y):\n  (x, y) = readline()\n  (x, y) = (x-1, y-1)\n  grid[x, y] = -2\n \n while(len(queue) > 0):\n  (x,y) = queue.popleft()\n  #print(\'Propagate\', (x+1,y+1), \'; d =\', grid[x,y])\n  for (u, v) in [(x-1, y), (x+1, y), (x,y-1), (x,y+1)]:\n   if u < 0 or v < 0 or u >= N or v >= M:\n    continue\n   if grid[u, v] == -1:\n    grid[u, v] = grid[x, y] + 1\n    queue.append((u, v))\n \n val = lambda x : str(x) if x != -2 else \'X\'\n \n for i in range(N):\n  print(\' \'.join(val(grid[i, j]) for j in range(M)))\n  \nfor _ in range(T):\n run()\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 6170642