#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll T, N, M;
    cin >> T;
    while(T--)
    {
        cin >> N >> M;
        vector <vector<int> > A(N+5, vector <int> (M+5));
        vector <vector<int> > B(N+5, vector <int> (M+5));
        for(int i = 0; i < N; i++) {for(int j = 0; j < M; j++) cin >> A[i][j];}
        for(int i = 0; i < N; i++) {for(int j = 0; j < M; j++) cin >> B[i][j];}
        cout << "NE" << endl;
    }
    return 0;
}