#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

vector<vector<int> > rotate(vector<vector<int> > &v) {
	int h = v.size(), w = v[0].size();
	
	vector<vector<int> > tmp(w, vector<int>(h));
	REP(i, h) REP(j, w) tmp[j][h - 1 - i] = v[i][j];
	
	return tmp;
}

int main() {
	int n, m;
	while (cin >> n >> m, n || m) {
		vector<vector<int> > w(n, vector<int>(n)), p(m, vector<int>(m));
		
		REP(i, n) REP(j, n) scanf("%d", &w[i][j]);
		REP(i, m) REP(j, m) scanf("%d", &p[i][j]);
		
		pii ans(INF, 0);
		REP(t, 4) {
			REP(y, n - m + 1) REP(x, n - m + 1) {
				bool ok = true;
				REP(i, m) if (ok) REP(j, m) if (ok) {
					int xx = x + j, yy = y + i;
					if (p[i][j] == -1) continue;
					if (w[yy][xx] != p[i][j]) ok = false;
				}
				if (ok) {
					int dx = -1, dy;
					REP(i, m) REP(j, m) {
						if (dx == -1 && p[i][j] != -1) {
							dx = j, dy = i;
						}
					}
					chmin(ans, pii(y + dy, x + dx));
				}
				
			}
			p = rotate(p);
		}
		
		if (ans == pii(INF, 0)) puts("NA");
		else {
			printf("%d %d\n", ans.se + 1, ans.fi + 1);
		}
	}
	
	return 0;
}