#include <cstdio>

using namespace std;

int pic[128][128];
int edge[64][64];

int ax, ay;

void rotate(int m)
{
	int temp[64][64];
	
	for (int i = 0; i < m; i++){
		for (int j = 0; j < m; j++){
			temp[i][j] = edge[m - j - 1][i];
		}
	}
	
	for (int i = 0; i < m; i++){
		for (int j = 0; j < m; j++){
			edge[i][j] = temp[i][j];
		}
	}
}

void search(int n, int m)
{
	for (int i = 0; i <= n - m; i++){
		for (int j = 0; j <= n - m; j++){
			bool flag = true;
			int px, py;
			px = py = 128;
			for (int dy = 0; dy < m; dy++){
				for (int dx = 0; dx < m; dx++){
					if (~edge[dy][dx] && (pic[i + dy][j + dx] != edge[dy][dx])){
						flag = false;
					}
					if (px == 128 && pic[i + dy][j + dx] == edge[dy][dx]){
						px = j + dx;
						py = i + dy;
					}
				}
			}
			if (flag == true && (ax == -1 || ay > py || (ay == py && ax > px))){
				ax = px;
				ay = py;
			}
		}
	}
	
}

int main()
{
	int n, m;
	
	while (scanf("%d %d", &n, &m), n){
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				scanf("%d", &pic[i][j]);
			}
		}
		
		for (int i = 0; i < m; i++){
			for (int j = 0; j < m; j++){
				scanf("%d", &edge[i][j]);
			}
		}
		
		ax = ay = -1;
		
		for (int i = 0; i < 4; i++){
			rotate(m);
			search(n, m);
		}
		
		if (~ax){
			printf("%d %d\n", ax + 1, ay + 1);
		}
		else {
			printf("NA\n");
		}
	}
	
	return (0);
}