#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

void turn(vvi& a)
{
	int n=a.size();
	vvi b=a;
	rep(i,n) rep(j,n)
		a[i][j]=b[n-1-j][i];
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vvi grid(n,vi(n));
		rep(i,n) rep(j,n) cin>>grid[i][j];
		vvi pat(m,vi(m));
		rep(i,m) rep(j,m) cin>>pat[i][j];
		
		pii res(999,999);
		rep(r,4){
			rep(i,n-m+1) rep(j,n-m+1){
				bool ok=true;
				rep(k,m) rep(l,m)
					if(pat[k][l]!=-1 && pat[k][l]!=grid[i+k][j+l]){
						ok=false;
						break;
					}
				if(!ok)
					continue;
				rep(k,m) rep(l,m)
					if(pat[k][l]!=-1)
						res=min(res,mp(i+k,j+l));
			}
			turn(pat);
		}
		if(res==mp(999,999))
			cout<<"NA"<<endl;
		else
			cout<<res.second+1<<" "<<res.first+1<<endl;
	}
	
	return 0;
}