#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

int n, m;
int w[100][100];
int p[50][50];
int p90[50][50];
int p180[50][50];
int p270[50][50];

void Match(int x, int y, int p[][50], int &resx, int &resy)
{
	int sx = -1, sy = -1;
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int val = p[i][j];
			if (val != -1)
			{
				if (sx == -1)
				{
					sx = x + i;
					sy = y + j;
				}
				if (val != w[x + i][y + j]) return;
			}
		}
	}
	if (sx < resx || (sx == resx && sy < resy))
	{
		resx = sx;
		resy = sy;
	}
}

void Solve()
{
	for (int i = 0; i < n - m; i++)
	{
		for (int j = 0; j < n - m; j++)
		{
			int resX = 100, resY = 100;
			Match(i, j, p, resX, resY);
			Match(i, j, p90, resX, resY);
			Match(i, j, p180, resX, resY);
			Match(i, j, p270, resX, resY);
			if (resX != 100)
			{
				printf("%d %d\n", resY + 1, resX + 1);
				return;
			}
		}
	}
	printf("NA\n");
}


bool ReadInput()
{
	scanf("%d%d", &n, &m);
	if (n == 0 && m == 0) return false;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++) scanf("%d", &w[i][j]);
	}
	for (int i = 0; i < m; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int val;
			scanf("%d", &val);
			p[i][j] = val;
			p90[-j + 3][i] = val;
			p180[-i + 3][-j + 3] = val;
			p270[j][-i + 3] = val;
		}
	}
	return true;
}

int main()
{
	while (ReadInput()) Solve();
}