#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)

int n, m, ar[1010][1010];

int main(){
    int t, i, j, k, l, a, b, x, y, res = 0, correct = 0;

    scanf("%d", &t);
    while (t--){
        scanf("%d %d", &n, &m);
        for (i = 0; i < n; i++){
            for (j = 0; j < m; j++){
                scanf("%d", &ar[i][j]);
            }
        }

        b = n >> 1, a = b - 1;
        for (j = 0, x = 0; j < m; j++){
            if (abs(ar[a][j] - ar[b][j]) > 10) x++;
        }
        double p = (1.0 * x) / m;

        res = 0;
        if (p > 0.75) res ^= 1;

        if (res) puts("YES");
        else puts("NO");
    }
    return 0;
}
