#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:667772160")
using namespace std;
struct __isoff {
  __isoff() {
    if (0) freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
    srand('C' + 'T' + 'A' + 'C' + 'Y' + 'M' + 'B' + 'A');
  }
  ~__isoff() {}
} __osafwf;
const unsigned long long p1 = 31;
const unsigned long long p2 = 29;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int infi = 1e9 + 7;
const long long inf = 1e18 + 7;
const long long dd = 5e5 + 7;
const long long mod = 1e9 + 7;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int h, w;
    cin >> h >> w;
    vector<vector<int> > T(h, vector<int>(w));
    for (long long i = 0; i < (long long)h; i++) {
      for (long long j = 0; j < (long long)w; j++) {
        int t;
        scanf("%d", &t);
        T[i][j] = t;
      }
    }
    int dx = 0;
    for (long long i = 0; i < (long long)w; i++) {
      int e = h / 2;
      int t = h / 2 - 1;
      dx += abs(T[e][i] - T[t][i]);
    }
    if (dx > 50 * w) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
