All Submissions


In Takeshi's Castle the prince has to travel from the starting point of a maze to the end point to save his princess.Some cells in the maze contains guard and the prince can not go through those cells.Movement between two cells is possible only if they both share a common edge.
Given the description of the maze you have to tell if the prince can save his princess or not.

INPUT
The first line of input will contain an integer t representing the number of test cases.It will be followed by t test cases.The first line of each test case will contain two integers n and m representing length and width of the maze.The next n lines will contain m integers,either 0 or 1.0 represents the the cell does not have a guard and 1 represents that the cell has a guard.
Starting Point will always be (1,1) and end point will always be (n,m).
Starting point and end point will never have a guard.

OUTPUT
Print YES if the prince can save his princess.Print NO if the prince can not save his princess.
Output of each test case must be in separate line.

CONSTRAINT
1 < t < 25
0 < n < 25
0 < m < 25

SAMPLE INPUT

2

1 4
0 0 0 0

1 4
0 0 1 0


SAMPLE OUTPUT

YES
NO


Problem Setter : Akshay Kumar

Languages: Brain,C,C++,Java,Pascal,Perl,PHP,Python,Ruby,Text

Time Limit: 1 Second(s)
Score: 0 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0