You will be given $$$T$$$ test cases.
In each test case, you are given a grid of size $$$N \times M$$$ containing integers. Your task is to choose exactly one number from each row so that the bitwise AND of all the chosen numbers is strictly greater than $$$0$$$.
Formally, you need to choose integers $$$c_1, c_2, \dots, c_{N}$$$ with $$$1 \le c_i \le M$$$ such that $$$$$$ a_{1,c_1} \;\&\; a_{2,c_2} \;\&\; \cdots \;\&\; a_{N,c_N} \; \gt \; 0, $$$$$$ where $$$a_{i,j}$$$ denotes the element in the $$$i$$$-th row and $$$j$$$-th column of the grid.
The first line contains a single integer $$$T$$$ ($$$1 \le T \le 2 \cdot 10^5$$$) — the number of test cases.
The first line of each test case contains two integers $$$N$$$ and $$$M$$$ — the number of rows and columns in the grid. Then follow $$$N$$$ lines, each containing $$$M$$$ integers — the elements of the grid $$$a_{i,j}$$$.
Constraints
$$$1 \le N, M \le 2 \cdot 10^5$$$
$$$0 \le a_{i,j} \le 10^{14}$$$
$$$1 \le \sum (N \cdot M) \le 2 \cdot 10^5$$$ over all test cases.
For each test case, print YES if it is possible to choose exactly one number from each row such that their bitwise AND is greater than $$$0$$$. Otherwise, print NO.
1 2 2 3 3 4 8
NO
1 2 3 3 5 8 4 1 16
YES
Test 1. The grid is:
We must choose one number from each row. Some possible pairs are: $$$(3,4) \Rightarrow 3 \& 4 = 0$$$ , $$$(3,8) \Rightarrow 3 \& 8 = 0$$$ . No matter how we choose, the bitwise AND is $$$0$$$. Hence the answer is NO.
3 3
4 8
Test 2. The grid is:
If we pick $$$5$$$ from the first row and $$$1$$$ from the second row, then $$$5 \& 1 = 1 \gt 0$$$. So a valid selection exists. Hence the answer is YES.
3 5 8
4 1 16
| Name |
|---|


