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