#P1474. TurnRight

TurnRight

    This summer, ELT and his classmates went toBeijing for a training of coding. ELT have never been to Beijing before, so atthe weekend, he together with some friends went to the National Museum, it'sfree for students!   TheNational Museum consists of many parts. One part of it is an exhibition ofAncient China From Xia Dynasty to Qing Dynasty, it needs a big room to show allthe things. What's more, there exist many walls to hang pictures. The boundaryof this room is walls except the entrance and exit.   Withwalls, an entrance and an exit, this room can be regarded as a maze. To make itsimple, this room is a R*C grid, wall is constructed at some edges of grid. Theentrance is always at the first row, and the exit is always at the last row,just like the picture .            

 ELTcan't remember his direction in maze, but he is a clever boy. He knew analgorithm called "Always Turn Right", it's procedure is as follows:at any grid of this room, if we can turn right(no wall at right side), then wemust turn right; if we can't turn right but can go straight forward, then wemust go forward; if we can't go forward but can turn left, then we must turnleft; if we can't even turn left, we just turn backward. In the picture above,if we use this algorithm, we'll visit these grids in order: Entrance --> (0,1) --> (0, 0) --> (0, 1) --> (0, 2) --> (1, 2) --> (1, 1) -->(1, 0) --> (2, 0) --> (1, 0) --> (1, 1) --> (2, 1) --> (2, 2)--> Exit. Very easy, doesn't it?

       ELTuses "Always Turn Right" algorithm to visit this room from entranceto exit, and then from exit to entrance. He wants to know whether he walked allgrids in the room. Now ELT is dizzy because the maze is too big, can you helphim?

Input

First line is an integer T, means T test cases. In each test case, the first line has four numbers: R, C, Ent_Column, Exit_Column. Ent_Column is the column number of entrance; Exit_Column is the column number of exit.
Then following 2*R-1 lines, 2*i line have C-1 numbers, the j-th number shows whether there is a wall between grid(i, j) and grid(i, j+1), 2*i+1 line have C numbers, the j-th number shows whether there is a wall between grid(i, j) and grid(i+1, j). Number 1 represents a wall, 0 represents no wall.
We guarantee that there exists a path from entrance to exit.
2 <= R, C <= 500
0 <= Ent_Column, Exit_Column < C

Output

If ELT can walk all grids in the room, print one line "YES", otherwise, print one line "NO".

Sample Input

1
3 4 1 2
0 0 0
1 1 0 1
0 0 0
0 0 0 0
1 0 0

Sample Output

</p>
YES

HINT

Source