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

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;
}

P pfunc(int a[51][51], int n, int s, int t)
{
	P p = P(-1,-1);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(a[i][j] != -1){
				p = P((i+s+1), (j+t+1));
				return p;
			}
		}
	}
	
	return p;
}

bool check(int pic[101][101], int r[51][51], int m, int s, int t)
{
	for(int i = 0; i < m; i++){
		for(int j = 0; j < m; j++){
			if(r[i][j] == -1){
				continue;
			}
			if(r[i][j] != pic[s+i][t+j]){
				return false;
			}
		}
	}
	
	return true;
}

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

int main()
{
	int pic[101][101], r[4][51][51], n, m;
	
	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 >> r[0][i][j];
				r[3][m-1-j][i] = r[2][m-1-i][m-1-j] = r[1][j][m-1-i] = r[0][i][j];
			}
		}
		
		if(func(pic, r, n, m)){
			cout << "NA" << endl;
		}
	}
	
	return 0;
}