#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int q, h, w, ai, first, second;
  cin >> q;
  while (q--) {
    cin >> h >> w;
    first = 0;
    second = 0;
    int lim = w * 2;
    for (size_t j = 0; j < h; ++j) {
      for (size_t k = 0; k < w; ++k) {
        cin >> ai;
        if (j == (h / 2 - 1)) {
          first += ai;
        } else if (j == (h / 2)) {
          second += ai;
        }
      }
    }
    int diverse = abs(first - second);
    if (diverse > lim) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
