#include #include #include #include using namespace std; int t,k,n,m,tp; int main(){ scanf("%d",&t); while(t--){ tp=0; scanf("%d%d",&n,&m); for(int i=1;i<=n;++i) for(int j=1;j<=m;++j){ scanf("%d",&k);if(k==1)tp++; } if(tp%2==1&&n%2==m%2||tp%2==0&&n%2!=m%2)printf("YES\n");else printf("NO\n"); } return 0; }