#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int a[100][100];
int b[50][50];
int n,m;

void rotate()
{
	int temp[50][50];
	memset(temp,0,sizeof(temp));

	rep(i,m) rep(j,m) temp [i][j] = b[j][m-1-i];

	rep(i,m) rep(j,m) b[i][j] = temp[i][j];

}

int main()
{
	while(cin >> n >> m)
	{
		if(n == 0 && m == 0) break;

		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));

		rep(i,n) rep(j,n) cin >> a[i][j];

		rep(i,m) rep(j,m) cin >> b[i][j];

		vector<pair<int,int> > v;

		rep(i,n-m)
		{
			rep(j,n-m)
			{
				bool flag = true;

				rep(k,m)
				{
					rep(l,m)
					{
						if(a[i+k][j+l] != b[k][l] && b[k][l] != -1)
						{
							flag = false;	
						}
					}
				}

				if(flag)
				{
					int minx=100,miny=100;
					bool flag2 = true;
					rep(k,m)
					{
						rep(l,m)
						{
							if(a[i+k][j+l] == b[k][l] && flag2)
							{
								miny = i+k;
								minx = j+l;
								flag2 = false;
							}
						}
					}
					v.push_back(make_pair(miny,minx));
				}
			}
		}

		rotate();

		rep(i,n-m)
		{
			rep(j,n-m)
			{
				bool flag = true;
				rep(k,m)
				{
					rep(l,m)
					{
						if(a[i+k][j+l] != b[k][l] && b[k][l] != -1)
						{
							flag = false;
						}
					}
				}

				if(flag)
				{
					int minx=100,miny=100;
					bool flag2 = true;
					rep(k,m)
					{
						rep(l,m)
						{
							if(a[i+k][j+l] == b[k][l] && flag2)
							{
								miny = i+k;
								minx = j+l;
								flag2 = false;	
							}
						}
					}
					v.push_back(make_pair(miny,minx));
				}
			}
		}

		rotate();

		rep(i,n-m)
		{
			rep(j,n-m)
			{
				bool flag = true;
				rep(k,m)
				{
					rep(l,m)
					{
						if(a[i+k][j+l] != b[k][l] && b[k][l] != -1)
						{
							flag = false;
						}
					}
				}

				if(flag)
				{
					int minx=100,miny=100;
					bool flag2 = true;
					rep(k,m)
					{
						rep(l,m)
						{
							if(a[i+k][j+l] == b[k][l] && flag2)
							{
								miny = i+k;
								minx = j+l;
								flag2 = false;	
							}
						}
					}
					v.push_back(make_pair(miny,minx));
				}
			}
		}

		rotate();

		rep(i,n-m)
		{
			rep(j,n-m)
			{
				bool flag = true;
				rep(k,m)
				{
					rep(l,m)
					{
						if(a[i+k][j+l] != b[k][l] && b[k][l] != -1)
						{
							flag = false;
						}
					}
				}

				if(flag)
				{
					int minx=100,miny=100;
					bool flag2 = true;
					rep(k,m)
					{
						rep(l,m)
						{
							if(a[i+k][j+l] == b[k][l] && flag2)
							{
								miny = i+k;
								minx = j+l;
								flag2 = false;	
							}
						}
					}
					v.push_back(make_pair(miny,minx));
				}
			}
		}

		if(v.size() != 0)
		{
			sort(v.begin(),v.end());
			cout << v[0].second+1 << " " << v[0].first+1 << endl;
		}
		else cout << "NA" << endl;
	}

	return 0;
}