#include <cstdio>
#include <cstring>

int mp[128][128];
int t[64][64];
int n, m;
int ax, ay;

using namespace std;

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

void search(int ty, int tx)
{
	int mx, my;
	mx = my = 128;
	for (int i = ty; i < ty + m; i++){
		for (int j = tx; j < tx + m; j++){
			if (t[i - ty][j - tx] != -1 && t[i - ty][j - tx] != mp[i][j]){
				return;
			}
			if (t[i - ty][j - tx] != -1 && t[i - ty][j - tx] == mp[i][j]){
				if (mx == 128){
					mx = j;
					my = i;
				}
			}
		}
	}
	if (my < ay || (my == ay && mx < ax)){
		ax = mx;
		ay = my;
	}
	return;
}

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