#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int main()
{
	int n, m;
	while (scanf("%d %d", &n, &m), n)
	{
		int view[100][100];
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < n; ++j)
				scanf("%d", &view[i][j]);
		int part[4][50][50];
		for (int i = 0; i < m; ++i)
			for (int j = 0; j < m; ++j)
				scanf("%d", &part[0][i][j]);

		for (int k = 1; k < 4; ++k)
			for (int i = 0; i < m; ++i)
				for (int j = 0; j < m; ++j)
					part[k][j][m-i-1] = part[k-1][i][j];

		int x, y;
		x = y = -1;
		for (int i = 0; i <= n-m; ++i)
		{
			for (int j = 0; j <= n-m; ++j)
			{
				for (int k = 0; k < 4; ++k)
				{
					bool ok = true;
					for (int ii = 0; ii < m && ok; ++ii)
						for (int jj = 0; jj < m && ok; ++jj)
							if (part[k][ii][jj] != -1 && part[k][ii][jj] != view[i+ii][j+jj])
								ok = false;

					if (ok)
					{
						int mj;
						for (mj = 0; part[k][0][mj] == -1; ++mj)
							;
						x = j + mj + 1;
						y = i + 1;
						goto End;
					}
				}
			}
		}
End:
		if (x != -1)
			printf("%d %d\n", x, y);
		else
			puts("NA");
	}

	return 0;
}