#include <bits/stdc++.h>
using namespace std;
int n, m, T, a[1000][1000];
int main() {
  cin >> T;
  while (T--) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
    int p = 0;
    for (int i = 1; i <= m; i++)
      if (abs(a[n / 2][i] - a[n / 2 + 1][i]) > 50) p++;
    if (p > m / 5) {
      cout << "YES" << endl;
      continue;
    }
    for (int i = 1; i <= n; i++)
      if (abs(a[i][m / 2] - a[i][m / 2 + 1]) > 50) p++;
    if (p > n / 5) {
      cout << "YES" << endl;
      continue;
    }
    cout << "NO" << endl;
  }
  return 0;
}
