#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000;
const int K = 70;
int q, n, m, p[MAXN][MAXN];
long long sqr(long long x) {
  if (x < 0) return -x;
  return x;
}
void solve() {
  scanf("%d %d", &n, &m);
  for (int i = (0); i < int(n); i++)
    for (int j = (0); j < int(m); j++) scanf("%d", &p[i][j]);
  long long score = 0;
  for (int i = (0); i < int(m); i++)
    score += sqr(p[(n - 1) / 2][i] - p[n / 2][i]);
  double ana = (double)score / m;
  if (score > K * m)
    puts("YES");
  else
    puts("NO");
}
int main() {
  scanf("%d", &q);
  while (q--) solve();
  return 0;
}
