#include <bits/stdc++.h>
int pic[666][666];
int h, w;
void each() {
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; i++)
    for (int j = 0; j < w; j++) scanf("%d", &pic[i][j]);
  double bad = 0;
  for (int i = 0; i < w; i++) {
    int p1 = pic[h / 2 - 1][i];
    int p2 = pic[h / 2 - 0][i];
    int delta = p1 - p2;
    if (delta < 0) delta *= -1;
    const int th = 64;
    if (delta > th) bad++;
  }
  double all = 0.2;
  all *= h;
  if (bad < all)
    printf("NO\n");
  else
    printf("YES\n");
  return;
}
int main() {
  int q;
  scanf("%d", &q);
  while (q--) each();
  return 0;
}
