#include<iostream>
#include<vector>
using namespace std;
int xPic;
int yPic;
int n;
int m;
int ansx = 100000;
int ansy = 100000;



/*vector<vector<int>> trim(vector<vector<int>> map)
{
for(int i = map.size() - 1; i >= 0; i--)
{
bool deleteFlag = true;
for(int j = 0; j < map[i].size(); j++)
{
if(map[i][j] != -1)
{
deleteFlag = false;
}

}
if(deleteFlag == true)
{
map.erase(map.begin() + i);
}

}


}		   */

bool checker(vector<vector<int>> map, vector<vector<int>> picture)
{
	bool flag = true;
	for(int i = 0; i < m; i++)
	{
		for(int j = 0; j < m; j++)
		{
			if(picture[i][j] != -1 && map[xPic + i][yPic + j] != picture[i][j])
			{
				flag = false;
				break;
			}
		}
		if(flag == false)
		{
			break;
		}
	}

	return flag;

}

vector<vector<int>> circle(vector<vector<int>> picture)
{
	vector<vector<int>> newPic;

	for(int i = 0; i < m; i++)
	{
		vector<int> line;
		for(int j = 0; j < m; j++)
		{
			line.push_back(0);

		}
		newPic.push_back(line);
	}

	for(int i = 0; i < m; i++)
	{
		for(int j = 0; j < m; j++)
		{
			newPic[j][m - 1 - i] = picture[i][j];
		}
	}
	return newPic;

}

int main()
{
	while(1)
	{
		ansx = 10000;
		ansy = 10000;
		cin >> n >> m;
		vector<vector<int>> map;
		vector<vector<int>> picture;

		if(n == 0 && m == 0)
		{
			return 0;
		}

		for(int i = 0; i < n; i++)
		{
			vector<int> line;
			for(int j = 0; j < n; j++)
			{
				int value;
				cin >> value;
				line.push_back(value);

			}
			map.push_back(line);
		}
		for(int i = 0; i < m; i++)
		{
			vector<int> line;
			for(int j = 0; j < m; j++)
			{
				int value;
				cin >> value;
				line.push_back(value);

			}
			picture.push_back(line);
		}
		bool flag = false;
		for(int i = 0; i < 4; i++)
		{
			for(int x = 0; x <= n - m && x <= ansx; x++)
			{
				for(int y = 0; y <= n - m; y++)
				{

					flag = false;
					xPic = x;
					yPic = y;
					//????§????????????????????????¨????????´??????????????????????????§??????????????¢??°????????????
					flag = checker(map, picture);
					//??§?¨?????????????????????§??????
					if(flag == true)
					{

						int bufx = x;
						int bufy = 100000;
						for(int j = 0; j < m; j++)
						{
							if(picture[0][j] != -1)
							{
								bufy = y + j;
								break;
							}
						}
						if(bufx < ansx || (bufx == ansx && bufy < ansy))
						{
							ansx = bufx;
							ansy = bufy;
						}
					}
					if(flag == true)
					{
						break;
					}
				}
				if(flag == true)
				{
					break;
				}
				//??????90????????¢?????????????????????????????????
				picture = circle(picture);
			}

		}
		if(ansx < 200)
		{
			cout << ansy + 1 <<" " << ansx + 1 << endl;
		}
		else
		{
			cout << "NA" << endl;
		}

	}
}