#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define LT(a,b,c,d) (((a)<(c))||((a)==(c)&&(b)<(d)))
#define INF 114514


int view[110][110];
int pict[4][55][55];
int maxX,maxP;
int mendoP[4],mendoQ[4];
int resX,resY;


bool findMendo(int i){
	FOR(p,1,maxP+1) FOR(q,1,maxP+1) if(pict[i][p][q]!=-1){ mendoP[i]=p; mendoQ[i]=q; return true; }
	return false;
}


bool match(int i, int offX, int offY){
	FOR(p,1,maxP+1) FOR(q,1,maxP+1) if(pict[i][p][q]!=-1 && pict[i][p][q]!=view[offX+p][offY+q]) return false;
	return true;
}

bool letMatch(int i){
	FOR(offX,0,maxX-maxP) FOR(offY,0,maxX-maxP){
		if(match(i,offX,offY)){
			if(LT(offX+mendoP[i], offY+mendoQ[i], resX, resY)){
				resX = offX+mendoP[i];
				resY = offY+mendoQ[i];
			}
			return true;
		}
	}
}

int main(){
	while(true){
		cin >> maxX >> maxP;			if(!maxX&&!maxP) return 0;

		FOR(x,1,maxX+1) FOR(y,1,maxX+1)
			cin >> view[x][y];

		FOR(p,1,maxP+1) FOR(q,1,maxP+1){
			int a;
			cin >> a;
			pict[0][p][q] = pict[1][q][maxP+1-p] = pict[2][maxP+1-p][maxP+1-q] = pict[3][maxP+1-q][p] = a;
		}
		
		FOR(i,0,4){
			findMendo(i);
		}

		resX=INF; resY=INF;
		FOR(i,0,4){
			letMatch(i);
		}

		if(resX==INF&&resY==INF){cout << "NA" << endl;}
		else{cout << resY << " " << resX << endl;}

	}
}