#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#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 main(){
	while(true){
		int maxX,maxY,maxP,maxQ;
		cin >> maxX >> maxP;			if(!maxX&&!maxP) return 0;
		maxY=maxX; maxQ=maxP;

		int view[maxX+1][maxY+1];
		FOR(x,1,maxX+1){
			FOR(y,1,maxY+1){
				cin >> view[x][y];
			}
		}

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

		int mendoP[4],mendoQ[4];
		FOR(i,0,4){
			FOR(p,1,maxP+1){
				FOR(q,1,maxQ+1){
					if(pict[i][p][q]!=-1){ mendoP[i]=p; mendoQ[i]=q; goto HEART; }
				}
			}
			HEART:
			int gomi=0;
		}

		int resX,resY;
		resX = resY = INF;

		FOR(i,0,4){
			FOR(offX,0,maxX-maxP){
				FOR(offY,0,maxY-maxQ){
					bool dekimasitaka = true;
					FOR(p,1,maxP+1){
						FOR(q,1,maxQ+1){
							if(pict[i][p][q]!=-1 && pict[i][p][q]!=view[offX+p][offY+q]){ dekimasitaka=false; goto NICOCHAN; }
						}
					}
					NICOCHAN:
					if(dekimasitaka){
						if(LT(offX+mendoP[i],offY+mendoQ[i],resX,resY)){
							resX=offX+mendoP[i];resY=offY+mendoQ[i];
						}
						goto HADAKIREI;
					}
				}
			}
			HADAKIREI:
			int gomi=0;
		}

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

	}

}