#include <iomanip>
#include <utility>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;


vector<vector<int> > rotate90(const vector<vector<int> > &am)
{
	int m = am.size();
	vector<vector<int> > r = vector<vector<int> >(m, vector<int>(m));

	for (int i = 0; i < m; i++)
		for (int j = 0; j < m; j++)
			r[j][m - i - 1] = am[i][j];
	return r;
}

pair<int, int> match(const vector<vector<int> > &an, const vector < vector<int> > &am)
{
	vector<vector<int> > a[4];
	a[0] = am;
	for (int i = 0; i < 3; i++)
	{
		a[i + 1] = rotate90(a[i]);
	}
	int m = am.size();
	int n = an.size() - m + 1;
	vector<pair<int, int> > result = vector<pair<int, int> >();
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			for (int k = 0; k < 4; k++)
			{
				for (int p = 0; p < m; p++) //??¨?????¢?????????????????§??????
				{

					bool ok = false;
					for (int q = 0; q < m; q++)
					{
						if (a[k][p][q] != -1)
						{
							if (a[k][p][q] != an[i + p][j + q])
							{
								ok = true;
								break;
							}
							else if (p + q == 2 * (m - 1))
							{
								for (int s = 0; s < m; s++)
								{
									bool ok2 = false;
									for (int t = 0; t < m; t++)
									{
										if (a[k][s][t] != -1)
										{
											result.push_back({ i + s + 1,j + t + 1 });
											ok2 = true;
											break;
										}
									}
									if (ok2) break;
								}
							}
						}
						else if (p + q == 2 * (m - 1))
						{
							for (int s = 0; s < m; s++)
							{
								bool ok2 = false;
								for (int t = 0; t < m; t++)
								{
									if (a[k][s][t] != -1)
									{
										result.push_back({ i + s + 1,j + t + 1 });
										ok2 = true;
										break;
									}
								}
								if (ok2) break;
							}
						}
					}
					if (ok) break;
				}

			}
			if (!result.empty())
			{
				int pos = 0;
				for (int h = 1; h < result.size(); h++)
				{
					if (result[pos].first > result[h].first)
						pos = h;
					else if (result[pos].first == result[h].first && result[pos].second > result[h].second)
						pos = h;
				}
				return result[pos];
			}
		}
	}
	return { -1,-1 };
}

int main()
{
	int n, m;
	vector<vector<int> > an, am;
	while (cin >> n >> m && n != 0)
	{
		an = vector<vector<int> >(n);
		for (int i = 0; i < n; i++)
		{
			an[i] = vector<int>(n);
			for (int j = 0; j < n; j++)
				cin >> an[i][j];
		}
		am = vector<vector<int> >(m);
		for (int i = 0; i < m; i++)
		{
			am[i] = vector<int>(m);
			for (int j = 0; j < m; j++)
				cin >> am[i][j];
		}
		pair<int, int> res = match(an, am);
		if (res.first > -1)
			cout << res.second << " " << res.first << endl;
		else
			cout << "NA" << endl;
	}

	return 0;
}