#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 llong;

char A[101][128], B[2][101][128];
llong mado[101][16], pic[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(A));

		int f = 0;
		rep(p, 4) {
			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 = mado[i+k][l] | pic[k][l];
						t = t ^ mado[i+k][l];
						if (t != 0) goto BREAK;
					}
					rep(k, m) if (B[f][0][k] > 0) {
						printf("%d %d\n", i+1, j+k+1);
						break;
					}
					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));
			}
			rep(i, m) rep(j, m) B[1-f][j][m-i-1] = B[f][i][j];
			f = 1 - f;
		}
		puts("NA");
NEXT:;
	}
	return 0;
}