Problem D

DEMANDING DILEMMA

A simple undirected graph is an ordered pair G = (V, E) where V is a non-empty set of vertices, and E is a set of unordered pairs (u, v) where u and v are in V and u v. If S is a set, define |S| as the size of S. An incidence matrix M is a |V| x |E| matrix where M(i, j) is 1 if edge j is incident to vertex i (edge j is either (i, u) or (u, i)) and 0 otherwise.

Given an n x m matrix, can it be an incidence matrix of a simple undirected graph G = (V, E) where |V| = n and |E| = m?

Program Input

The first line of the input contains an integer t (1 ≤ t ≤ 41), the number of test cases.

Each test case starts with a line with two integers n (1 ≤ n ≤ 8) and m (0 ≤ m n(n-1)/2). Then n lines containing m integers (0’s or 1’s) each follow such that the jth number on the ith line is M(i, j).

Program Output

For each test case print “Yes” if the incidence matrix given in the input can be an incidence matrix of some simple undirected graph, otherwise print “No”.

Sample Input & Output

INPUT

3
3 3
1 1 0
0 1 1
1 0 1
3 1
1
1
0
3 3
1 1 0
1 1 1
1 0 0
OUTPUT
Yes
Yes
No

Calgary Collegiate Programming Contest 2008