In Chefland, there is a monthly robots competition. In the competition, a grid table of N rows and M columns will be used to place robots. A cell at row i and column j in the table is called cell (i, j). To join this competition, each player will bring two robots to compete and each robot will be placed at a cell in the grid table. Both robots will move at the same time from one cell to another until they meet at the same cell in the table. Of course they can not move outside the table. Each robot has a movable range. If a robot has movable range K, then in a single move, it can move from cell (x, y) to cell (i, j) provided (|i-x| + |j-y| <= K). However, there are some cells in the table that the robots can not stand at, and because of that, they can not move to these cells. The two robots with the minimum number of moves to be at the same cell will win the competition.

Chef plans to join the competition and has two robots with the movable range K1 and K2, respectively. Chef does not know which cells in the table will be used to placed his 2 robots, but he knows that there are 2 cells (1, 1) and (1, M) that robots always can stand at. Therefore, he assumes that the first robot is at cell (1, 1) and the other is at cell (1, M). Chef wants you to help him to find the minimum number of moves that his two robots needed to be at the same cell and promises to give you a gift if he wins the competition. 

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
-  The first line of each test case contains 4 space-separated integers N M K1 K2 denoting the number of rows and columns in the table and the movable ranges of the first and second robot of Chef.
-  The next N lines, each line contains M space-separated numbers either 0 or 1 denoting whether the robots can move to this cell or not (0 means robots can move to this cell, 1 otherwise). It makes sure that values in cell (1, 1) and cell (1, M) are 0.

-----Output-----
For each test case, output a single line containing the minimum number of moves that Chef’s 2 robots needed to be at the same cell. If they can not be at the same cell, print -1.

-----Constraints-----
- 1 ≤ T ≤ 10
- 1 ≤ N, M ≤ 100
- 0 ≤ K1, K2 ≤ 10

----- Subtasks -----
Subtask #1 : (25 points) 
-  K1 = K2 = 1 

Subtask # 2 : (75 points) 
Original Constraints

-----Example-----
Input:
2
4 4 1 1
0 1 1 0
0 1 1 0
0 1 1 0
0 0 0 0
4 4 1 1
0 1 1 0
0 1 1 0
0 1 1 0
1 0 0 1

Output:
5
-1

-----Explanation-----
Example case 1. Robot 1 can move (1, 1) -> (2, 1) -> (3, 1) -> (4, 1) -> (4, 2) -> (4, 3), and robot 2 can move (1, 4) -> (2, 4) -> (3, 4) -> (4, 4) -> (4, 3) -> (4, 3), they meet at cell (4, 3) after 5 moves.
Example case 2. Because the movable range of both robots is 1, robot 1 can not move from (3, 1) to (4, 2), and robot 2 can not move from (3, 4) to (4, 3. Hence, they can not meet each other.

```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\n\ndef spaces(a,n,m,k,visit1,visit2,dist,position):\n queue = [position]\n lastedit = []\n dist[position[0]][position[1]] = 0 \n while queue!=[]:\n  point = queue[0]\n  i = point[0]\n  j = point[1]\n  #print 'point',i,j\n  if visit1[i][j]==False:\n   visit1[i][j] = True\n   startx = max(i-k,0)\n   endx = min(i+k,n-1)\n   for x in range(startx,endx+1):\n    starty = max(0,j+abs(x-i)-k)\n    endy = min(m-1,j-abs(x-i)+k)\n    for y in range(starty,endy+1):\n     if (a[x][y]==0 and visit1[x][y]==False):\n      if visit2[x][y]==True:\n       lastedit.append([x,y])\n      #print x,y,\n      if dist[x][y]>dist[i][j]+1:\n       dist[x][y]=dist[i][j]+1\n       queue.append([x,y])\n  #print queue,dist\n  queue = queue[1:]\n  #print\n return lastedit\n\nfor t in range(int(input())):\n n,m,k1,k2 = list(map(int,input().split()))\n a = []\n for i in range(n):\n  a.append(list(map(int,input().split())))\n #print a\n value = sys.maxsize\n listing = []\n visit1 = [[False for i in range(m)]for j in range(n)]\n visit2 = [[False for i in range(m)]for j in range(n)]\n dist1 = [[sys.maxsize for i in range(m)]for j in range(n)]\n dist2 = [[sys.maxsize for i in range(m)]for j in range(n)]\n if k1<=k2:\n  spaces(a,n,m,k1,visit1,visit2,dist1,[0,0])\n else:\n  spaces(a,n,m,k2,visit1,visit2,dist1,[0,m-1])\n  listing = spaces(a,n,m,k1,visit2,visit1,dist2,[0,0])\n if k1<k2:\n  listing = spaces(a,n,m,k2,visit2,visit1,dist2,[0,m-1])\n #print visit1\n #sprint visit2\n if k1==k2:\n  if dist1[0][m-1]==sys.maxsize:\n   print('-1')\n  else:\n   print(int((dist1[0][m-1]+1)/2))\n else:\n  d = len(listing)\n  for i in range(d-1,-1,-1):\n   x = listing[i][0]\n   y = listing[i][1]\n   if visit1[x][y]==True and dist2[x][y]<value:\n    value = dist2[x][y]\n  if value!=sys.maxsize:\n   print(value)\n  else:\n   print('-1')\n\n\n\n\n   \n   \n"
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 14125