#include <cstdio>
#include <cstring>

#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) REP(i, 0, n)
typedef unsigned long long ll;

#define INF (1<<20)
int mado[100][100], pic[4][50][50], offset[4];

int main()
{
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n) rep(j, n) scanf("%d", &mado[i][j]);
		rep(i, m) rep(j, m) scanf("%d", &pic[0][i][j]);

		rep(k, 3) rep(i, m) rep(j, m)
			pic[k+1][i][j] = pic[k][m-1-j][i];
		rep(k, 4) {
			offset[k] = 0;
			rep(j, m) { if (pic[k][0][j] > -1) break; offset[k]++; }
		}

		int resk, resx, resy;
		resk = resx = resy = INF;
		rep(k, 4) rep(i, n-m+1) rep(j, n-m+1) {
			bool ok = true;
			rep(x, m) rep(y, m) {
				if (pic[k][x][y] > -1 && (pic[k][x][y] ^ mado[i+x][j+y]) != 0) {
					ok = false;
					goto NEXT;
				}
			}
			if (resx > i || resx == i && resy > j) {
				resk = k;
				resx = i;
				resy = j + offset[k];
//{rep(i, m) { rep(j, m) printf("%2d ", pic[resk][i][j]);puts(""); }}
			}
NEXT:;
		}
		if (resx == INF) {
			puts("NA");
		}
		else {
			printf("%d %d\n", resy+1, resx+1);
		}
	}
	return 0;
}