#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

vector<vector<int>>rot(vector<vector<int>>v) {
	vector<vector<int>>rotated(v);
	for (int i = 0; i < v.size(); ++i) {
		for (int j = 0; j < v.size(); ++j) {
			rotated[i][j]=v[v.size()-j-1][i];
		}
	}
	return rotated;
}

pair<int,int> check(vector<vector<int>>&f, vector<vector<int>>&p, int l, int u) {
	pair<int,int>ans(10000,10000);;
	for (int x = l; x < l + p.size(); ++x) {
		for (int y = u; y < u + p.size(); ++y) {
			if (p[y - u][x - l] != -1) {
				ans=min(ans,make_pair(y,x));
				if (f[y][x] != p[y - u][x - l])return make_pair(10000, 10000);

			}
		}
	}
	return ans;
}
int main() {
	while (true) {
		int N,M;cin>>N>>M;
		if(!N)break;
		vector<vector<int>>field(N,vector<int>(N));
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				cin>>field[i][j];
			}
		}
		vector<vector<int>>picture(M,vector<int>(M));
		for (int i = 0; i < M; ++i) {
			for (int j = 0; j < M; ++j) {
				cin >> picture[i][j];
			}
		}
		pair<int,int>ans(10000,10000);
		for (int l = 0; l <= N - M; ++l) {
			for (int u = 0; u <= N - M; ++u) {
				for (int k = 0; k < 4; ++k) {
					picture=rot(picture);
					ans=min(ans,check(field,picture,l,u));
				}
			}
		}
		if (ans.first == 10000) {
			cout<<"NA"<<endl;
		}
		else {
			cout<<ans.second+1<<" "<<ans.first+1<<endl;
		}
	}
	return 0;
}
