#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

typedef pair<int,int> P;

bool comp(const P& p1, const P& p2)
{
	if(p1.second == p2.second){
		return p1.first < p2.first;
	}
	
	return p1.second < p2.second;
}

int w, h;
void resize(int r[4][51][51], int a[51][51], int n)
{
	int w1, w2, h1, h2;
	w1 = h1 = 0;
	w2 = h2 = n-1;
	
	bool f = true;
	for(; w1 < n; w1++){
		for(int i = 0; i < n; i++){
			if(a[i][w1] != -1){
				f = false;
				break;
			}
		}
		if(!f){
			break;
		}
	}
	
	f = true;
	for(; w2 >= 0; w2--){
		for(int i = 0; i < n; i++){
			if(a[i][w2] != -1){
				f = false;
				break;
			}
		}
		if(!f){
			break;
		}
	}
	
	f = true;
	for(; h1 < n; h1++){
		for(int i = 0; i < n; i++){
			if(a[h1][i] != -1){
				f = false;
				break;
			}
		}
		if(!f){
			break;
		}
	}
	
	f = true;
	for(; h2 >= 0; h2--){
		for(int i = 0; i < n; i++){
			if(a[h2][i] != -1){
				f = false;
				break;
			}
		}
		if(!f){
			break;
		}
	}
	w = w2 - w1;
	h = h2 - h1;
	
	for(int i = 0; i <= h; i++){
		for(int j = 0; j <= w; j++){
			r[3][w-j][i] = r[2][h-j][w-j] = r[1][j][h-i] = r[0][i][j] = a[i+h1][j+w1];
		}
	}
	
	return ;
}

P check(int pic[101][101], int r[51][51], int n, int h, int w)
{
	P p = P(-1, -1), q;
	
	bool f = true;
	int mw = n-w, mh = n-h;
	for(int i = 0; i < mh && f; i++){
		for(int j = 0; j < mw && f; j++){
			bool f2 = true, f3 = true;
			for(int k = 0; k <= h && f3; k++){
				for(int l = 0; l <= w && f3; l++){
					if(r[k][l] == -1){
						continue;
					}
					if(pic[i+k][j+l] != r[k][l]){
						f3 = false;
					}
					if(f2){
						f2 = false;
						q = P(i+k+1, j+l+1);
					}
				}
			}
			
			if(f3){
				p = q;
				f = false;
			}
		}
	}
	
	return p;
}

bool func(int pic[101][101], int r[4][51][51], int n, int m)
{
	bool f = true;
	int s, t;
	vector<P> vec;
	P p;
	for(int i = 0; i < 4; i++){
		if(i%2 == 0){
			s = h;
			t = w;
		} else {
			s = w;
			t = h;
		}
		
		p = check(pic, r[i], n, s, t);
		if(p.first != -1){
			f = false;
			vec.push_back(p);
		}
	}
	
	if(!f){
		sort(vec.begin(), vec.end(), comp);
		cout << vec[0].second << " " << vec[0].first << endl;
	}
	
	return f;
}

int main()
{
	int n, m, pic[101][101], r[4][51][51], a[51][51];
	
	while(cin>>n>>m && (n+m)){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> pic[i][j];
			}
		}
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				cin >> a[i][j];
			}
		}
		resize(r, a, m);
		
		if(func(pic, r, n, m)){
			cout << "NA" << endl;
		}
	}
	
	return 0;
}