#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int n,m; while(cin>>n>>m,n){
		int l[n][n],p[4][m][m];
		rep(i,n)rep(j,n)cin>>l[i][j];
		rep(i,m)rep(j,m)cin>>p[0][i][j];
		rep(i,3)rep(y,m)rep(x,m)p[i+1][m-1-x][y]=p[i][y][x];
		int ay=n,ax=n;
		rep(d,4)rep(y,n-m+1)rep(x,n-m+1){
			bool sc=1,f=0; int ty=n,tx=n;
			rep(i,m)rep(j,m){
				if(!sc||p[d][i][j]==-1)continue;
				if(!f)ty=y+i,tx=x+j,f=1;
				if(p[d][i][j]!=l[y+i][x+j])sc=0;
			}
			if(sc&&(ty<ay||ty==ay&&tx<ax))ay=ty,ax=tx;
		}
		if(ay<n&&ax<n)cout<<ax+1<<" "<<ay+1<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}