#include <cstdio>
#include <cstring>

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

char A[101][128], B[2][101][128], C[101][128];
llong mado[101][16], pic[101][16], mask[101][16];
int n, m;
int main()
{
	while (scanf("%d%d", &n, &m), (n|m)) {
		memset(A, 0, sizeof(A));
		memset(B[0], 0, sizeof(B));
		int t;
		rep(i, n) rep(j, n) { scanf("%d", &t); A[i][j] = t+1; }
		rep(i, m) rep(j, m) { scanf("%d", &t); B[0][i][j] = t+1; }

		memcpy(mado, A, sizeof(mado));
		memcpy(C, B[0], sizeof(C));

		int f = 0;
		bool found = false;
		int resx = INF, resy = INF;
		rep(p, 4) {
			rep(i, m) rep(j, m) C[i][j] = (C[i][j] > 0) ? 0xff : 0x00;
			memcpy(mask, C, sizeof(mask));
			memcpy(pic, B[f], sizeof(pic));
			rep(i, n-m+1) {
				rep(j, n-m+1) {
					rep(k, m) rep(l, (m>>3)+1) {
						llong t = (mask[k][l] & mado[i+k][l]) ^ pic[k][l];
						if (t != 0) goto BREAK;
					}
					rep(k, m) if (B[f][0][k] > 0) {
						if (resy > i+1) {
							resx = j+k+1;
							resy = i+1;
						}
						else if (resy == i+1 && resx > j+k+1) {
							resx = j+k+1;
							resy = i+1;
						}
						break;
					}
					if (resx == INF && resy == INF) goto BREAK;
					found = true;
					goto NEXT;
BREAK:
					rep(k, m) rep(l, (m>>3)+1) {
						mado[i+k][l] >>= 8;
						mado[i+k][l] |= (mado[i+k][l+1] << 56) & 0xff;
					}
				}
				memcpy(mado, A, sizeof(A));
			}
NEXT:;
			rep(i, m) rep(j, m) {
				B[1-f][j][m-i-1] = B[f][i][j];
				C[j][m-i-1] = C[i][j];
			}
			f = 1 - f;
		}
		if (found) printf("%d %d\n", resx, resy);
		else puts("NA");
	}
	return 0;
}