#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#define debug cout

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,-1,1,-1,0};
const int dy[]={0,0,1,-1,1,-1,-1,1,0};

int a[110][110],b[60][60];
int n,m,resx,resy,offset;

bool fit(int y,int x){
	rep(i,m)rep(j,m){
		if(b[i][j]==-1)continue;
		if(a[y+i][x+j]!=b[i][j])return false;
	}
	return true;
}

void rotate(){
	int c[60][60];
	rep(i,m)rep(j,m){
		c[i][j]=b[m-j-1][i];
	}
	rep(i,m)rep(j,m)b[i][j]=c[i][j];
}

int main() {
	IL{
		cin>>n>>m;
		if(n==0&&m==0)break;
		rep(i,n)rep(j,n)cin>>a[i][j];
		rep(i,m)rep(j,m)cin>>b[i][j];
		resx=resy=n;
		rep(iii,4){
			rep(i,m)if(b[0][i]!=-1){
				offset=i;
				break;
			}
			rep(i,n-m+1)rep(j,n-m+1){
				if(fit(i,j)){
					if(resy>i||resy==i&&resx>j+offset){
						resx=j+offset;
						resy=i;
					}
				}
			}
			rotate();
		}
		if(resx<n)cout<<resx+1<<" "<<resy+1<<endl;
		else cout<<"NA"<<endl;
	}
	return 0;
}