Demanding Dilemma

A simple undirected graph is an ordered pair G = (V, E) where V is a non-empty set of vertices, and Eisasetofunorderedpairs(u,v)whereuandvareinV andu̸=v. IfSisaset,define|S|asthe size of S. An incidence matrix M is a |V|×|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 × m matrix, can it be an incidence matrix of a simple undirected graph G = (V, E) where |V | = n and |E| = m? 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 j-th number on the i-th line is M(i,j). 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 3 33 110 011 101 31 1 1 0 33 110 111 100 Sample Output Yes Yes No