Honey Kingdom, a nation built by bees, all areas are developed in a regular hexagonal (正六邊形) pattern. To facilitate development, they use a unique coordinate system where each hexagonal cell is represented by coordinate (x,y) as shown below:
The map is structured such that the first row has coordinates:
(1,1) , (1,2) , ... , (1,M)
The second row then has:
(2,1) , (2,2) , ... , (2,M)
...
In this system, each cell (x,y) is positioned between (x−1,y) and (x−1,y+1).
For any cell located at (x,y), its neighboring cells are:
(x-1,y) , (x-1,y+1) , (x,y-1) , (x,y+1) , (x+1,y-1) , (x+1,y)
Now, Bee Agent User333 has been assigned T missions, each involving a different map. On each map, the starting point is always (1,1) and the destination is (N,M).
Each cell on the map contains specific information denoted by Ai,j :
User333 needs to determine whether they can reach the destination on each map using only flight and magic circles.
The first line of input contains a positive integer T, representing the number of maps.
For each map, the input is structured as follows:
The first line contains two positive integers N and M, representing the map's size N × M.
The next N lines each contain M entries:
A1,1 , A1,2 , ... , A1,MConstraints
For each map, output a single line containing "YES" if it is possible to reach the destination from the start point, and "NO" otherwise (without quotes).
Please remember to print "\n" at the end of each line.