#include <iostream>
using namespace std;
int n, m, a[111][111], b[55][55];
void rotate() {
	int z[55][55];
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			z[i][j] = b[m - j - 1][i];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < m; j++) {
			b[i][j] = z[i][j];
		}
	}
}
int main() {
	while (cin >> n >> m, n | m) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> a[i][j];
			}
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < m; j++) {
				cin >> b[i][j];
			}
		}
		int rx = n, ry = n;
		for (int i = 0; i < 4; i++) {
			int sx = m;
			for (int j = m - 1; j >= 0; j--) {
				if (b[0][j] != -1) sx = j;
			}
			for (int j = 0; j <= n - m; j++) {
				for (int k = 0; k <= n - m; k++) {
					bool flag = true;
					for (int ey = j; ey < j + m; ey++) {
						for (int ex = k; ex < k + m; ex++) {
							int v = b[ey - j][ex - k];
							if (v != -1 && a[ey][ex] != v) flag = false;
						}
					}
					if (flag && (ry > j || (ry == j && rx > k + sx))) {
						rx = k + sx, ry = j;
					}
				}
			}
			rotate();
		}
		if (rx == n && ry == n) cout << "NA" << endl;
		else cout << rx + 1 << ' ' << ry + 1 << endl;
	}
	return 0;
}