#include<iostream>
#include<cstring>

typedef std::pair<int, int> P;

int n, m;
int scene[101][101];

P ok(int pic[51][51]){
	for (int i = 0; i <= n - m; i++){
		for (int j = 0; j <= n - m; j++){
			P ret;
			for (int k = m - 1; k >= 0; k--){
				for (int l = m - 1; l >= 0; l--){
					if (pic[k][l] != -1 && scene[i + k][j + l] != pic[k][l])goto next;
					else if (pic[k][l] != -1)ret = P(j + l, i + k);
				}
			}
			return ret;
		next:;
		}
	}
	return P(10000, 10000);
}

void r(int pic[51][51]){
	int out[51][51];
	int ox = 0, oy = 0;
	for (int i = 0; i < m; i++){
		for (int j = m - 1; j >= 0; j--){
			out[oy][ox] = pic[j][i];
			ox++;
			if (ox == m)ox = 0, oy++;
		}
	}
	memcpy(pic, out, sizeof(out));
}

int main(){
	while (true){
		int pic[51][51];

		std::cin >> n >> m;
		if (n == 0 && m == 0)break;

		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				std::cin >> scene[i][j];
			}
		}

		for (int i = 0; i < m; i++){
			for (int j = 0; j < m; j++){
				std::cin >> pic[i][j];
			}
		}

		P min(10000, 10000);
		for (int i = 0; i < 4; i++){
			P p = ok(pic);
			r(pic);
			if (p.second < min.second)min = p;
			else if (p.second == min.second&&p.first < min.first)min = p;
		}

		if (min.first == 10000)std::cout << "NA" << std::endl;
		else std::cout << min.first + 1 << " " << min.second + 1 << std::endl;
	}

	return 0;
}