Codeforces Round 777 (Div. 2) |
---|
Finished |
Madoka's father just reached $$$1$$$ million subscribers on Mathub! So the website decided to send him a personalized award — The Mathhub's Bit Button!
The Bit Button is a rectangular table with $$$n$$$ rows and $$$m$$$ columns with $$$0$$$ or $$$1$$$ in each cell. After exploring the table Madoka found out that:
For example, in the first illustration the red subrectangle is nice, but in the second one it's not, because it's contained in the purple subrectangle.
Help Madoka to determine whether the table is elegant.
Each test contains multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \le t \le 200$$$) — the number of test cases. Description of the test cases follows.
The first line of each test case contains two positive integers $$$n, m$$$ ($$$1 \le n, m \le 100$$$).
The next $$$n$$$ lines contain strings of length $$$m$$$ consisting of zeros and ones — the description of the table.
It is guaranteed that the sum of the values of $$$n$$$ and the sum of the values of $$$m$$$ for all test cases do not exceed $$$777$$$.
For each test case print "YES" if its table is elegant or print "NO" otherwise.
You may print each letter in any case (for example, "YES", "Yes", "yes", "yEs" will all be recognized as positive answer).
53 31000110113 31101111101 5011114 5111110101001000010003 2110011
YES NO YES NO YES
In the second test case the table is not elegant, because the red and the purple subrectangles are nice and intersect.
In the fourth test case the table is not elegant, because the red and the purple subrectangles are nice and intersect.
Name |
---|