#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  int q;
  cin >> q;
  while (q--) {
    int n, m;
    cin >> n >> m;
    long long s1 = 0;
    long long s2 = 0;
    int t = n / 2;
    long long s = 0;
    vector<int> a, b;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int x;
        cin >> x;
        a.push_back(x);
        if (i < t)
          s1 += x;
        else
          s2 += x;
        if (i == t) s += abs(b[j] - x);
      }
      swap(a, b);
      a.clear();
    }
    long double ss = s;
    ss /= m;
    if (ss > 20)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
