#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) reps(i,0,a)
#define reps(i,a,b) for(int i = (a); i < (b); i++)
#define INF 1e9
int n,m;
int field[101][101];
int photo[4][51][51];
bool check(int x, int y, int k) {
	rep(i, m) rep(j, m) {
		if(photo[k][i][j] != field[i + y][j + x] && photo[k][i][j] != -1) return false;
	}
	return true;
}
void top(int &x, int &y, int k) {
	rep(i,m)rep(j,m) {
		if(photo[k][i][j] != -1) {
			x += j;
			y += i;
			return;
		}
	}
}
int main() {
	while(cin >> n >> m,n,m){
		rep(i, n)rep(j, n) scanf("%d",&field[i][j]);
		rep(i, m)rep(j, m) scanf("%d",&photo[0][i][j]);
		reps(k, 1, 4)rep(i, m)rep(j, m) photo[k][j][m - i - 1] = photo[k-1][i][j];
		int ax = INF, ay = INF;
		rep(k, 4) rep(i, n - m + 1) rep(j, n - m + 1) {
			if(check(j, i, k)) {
				int nx = j, ny = i;
				top(nx, ny, k);
				if(ny < ay || (ny == ax && nx < ax)) ax = nx,ay = ny;
			}
		}
		if(ax == INF) puts("NA");
		else printf("%d %d\n", ax + 1, ay + 1);
	}
	return 0;
}