#include <iostream>
#include <vector>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstring>	// require memset
//#include <fstream>	// require freopen

using namespace std;

typedef pair<int, int> P; // row, col order

int scene[100][100];
int pic[50][50];
int n, m;

P check_pic (int row, int col )
{
	P res(-1,-1);
	for (int i = 0; i < m; ++i ){
		for (int j = 0; j < m; ++j ){
			if (pic[i][j] == -1 ){
				continue;
			}else{
				if (pic[i][j] == scene[row + i][col + j] ){
					if (res.first == -1 && res.second == -1){
						res.first = row + i;
						res.second = col + j;
					} // end if
					continue;
				}else{
					return P(-1,-1);
				} // end if
			} // end if
		} // end for
	} // end for

	return res;
}

void rotate90 (void )
{
	int res[m][m];
	
	memset (res, 0, sizeof(res ) );
	
	for (int i = 0; i < m; ++i ){
		for (int j = 0; j < m; ++j ){
			res[j][m - 1 - i] = pic[i][j];
		} // end for
	} // end for

	for (int i = 0; i < m; ++i ){
		for (int j = 0; j < m; ++j ){
			pic[i][j] = res[i][j];
		} // end for
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.sip", "r", stdin );

	while (cin >> n >> m && n && m ){
		memset (scene, 0, sizeof (scene ) );
		memset (pic, 0, sizeof (pic ) );
		for (int i = 0; i < n; ++i){
			for (int j = 0; j < n; ++j ){
				cin >> scene[i][j];
			} // end for
		} // end for

		for (int i = 0; i < m; ++i ){
			for (int j = 0; j < m; ++j ){
				cin >> pic[i][j];
			} // end for
		} // end for

		vector <P> res;

		for (int k = 0; k < 4; ++k ) {
			for (int i = 0; i < n - m + 1; ++i ){
				for (int j = 0; j < n - m + 1; ++j ){
					P r = check_pic (i,j );
					if (r.first != -1 || r.second != -1 ){
						res.push_back(r);
					} // end if
				} // end for
			} // end for
			rotate90();
		} // end for

		if (res.empty() ){
			cout << "NA" << endl;
		}else{
			sort (res.begin(), res.end() );
			cout << (res[0].second + 1 ) << ' ' << (res[0].first + 1) << endl;
		} // end if
	} // end loop
		
	return 0;
}