#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int n, m, pic[110][110], pat[55][55], sub[55][55];

typedef pair< int, int > pii;

void rot() {
	for_(i,0,m) for_(j,0,m) sub[m - j - 1][i] = pat[i][j];
	for_(i,0,m) for_(j,0,m) pat[i][j] = sub[i][j];
}

int main() {
	while (cin >> n >> m, n) {
		for_(i,0,n) for_(j,0,n) cin >> pic[i][j];
		for_(i,0,m) for_(j,0,m) cin >> pat[i][j];
		
		pii ans(n, n);
		
		for_(r,0,4) {
			pii p(n, n);
			
			for (int i = 0; i < n - m + 1 && p.first == n; ++i) {
				for (int j = 0; j < n - m + 1 && p.first == n; ++j) {
					bool flag = true;
					
					for (int ii = 0; ii < m && flag; ++ii) for (int jj = 0; jj < m && flag; ++jj) {
						if (pat[ii][jj] == -1) continue;
						flag &= (pic[i + ii][j + jj] == pat[ii][jj]);
						if (flag && p.first == n) p = pii(i + ii, j + jj);
					}
					
					if (!flag) p = pii(n, n);
				}
			}
			
			ans = min(ans, p);
			
			rot();
		}
		
		if (ans.first == n) cout << "NA" << endl;
		else cout << ans.second + 1 << " " << ans.first + 1 << endl;
	}
}