#include <iostream>

using namespace std;

int main()
{
	int t, n;
	cin >> t >> n;
	
	long long a[n], b[n];
	for (int k = 0; k < t; k++){
		for (int i = 0; i < n; i++)
			cin >> a[i];
		for (int j = 0; j < n; j++)
			cin >> b[j];
	}
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (a[i] != 0 && b[j] != 0){
				if (a[i] == b[j]){
					if ((i%2!= 0 && j%2 != 0) || (i%2 == 0 && j%2 == 0))
						cout << "DA" << endl;
					else cout << "NE" << endl;
				}
				else {
					if (a[i]*-1 == b[j]){
						if (i == 0 || i == n-1){
							if (j%2 != 0)
								cout << "DA" << endl;
							else cout << "NE" << endl;
						}
						
						else {
							if (j%2==0)
								cout << "DA" << endl;
							else cout << "NE" << endl;
						}
					}
					
				}
			}	
		}
	}
	
	return 0;
	
}