#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int w, h;
    scanf("%d%d", &h, &w);
    int a[500][500];
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        scanf("%d", &a[i][j]);
      }
    }
    int sum = 0;
    int Upper = h / 2 - 1;
    int lower = h / 2;
    for (int j = 0; j < w; j++) {
      if (abs(a[Upper][j] - a[lower][j]) > 15) sum++;
    }
    if (sum > w / 2)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
