#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FFOR(i,a,b) for(int i=(a);i<=(b);i++)
#define REP(i,b) FOR(i,0,b)
#define RREP(i,b) FFOR(i,1,b)
#define PB push_back
#define F first
#define S second
#define BE(c) c.begin(),c.end()
using namespace std;
typedef long long LL;
typedef LL ut;
typedef long double ld;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef vector<ut> VI;
typedef pair<ut,pr> ppr;
typedef priority_queue<pr,Vpr, greater<pr> > PQ;
const int SIZE=5+3*1e+4;
const ut INF=1<<30;
const ld eps=1e-6;
const LL mod=7+1e+9;

int N, M;
int pic[128][128], snip[64][64];

void rot(){
	int next_pic[128][128];
	
	REP(i,N)
		REP(j,N)
			next_pic[j][N - i - 1] = pic[i][j]; 
	
	REP(i,N)
		REP(j,N)
			pic[i][j] = next_pic[i][j];
}

int main(){
	while(cin >> N >> M && (N || M)){
		int p, s;
		memset(pic, 0, sizeof(pic));
		memset(snip, 0, sizeof(snip));
		Vpr ans;
		REP(i,N){
			REP(j,N){
				scanf("%d", &p);
				pic[i][j] = p;
			}
		}
		REP(i,M){
			REP(j,M){
				scanf("%d", &s);
				snip[i][j] = s;
			}
		}
		REP(l,4){
			REP(i,N-M+1)REP(j,N-M+1){
				bool ok = true;
				REP(a,M){
					REP(b,M){
						if(snip[a][b] == -1)
							continue;
						if(!(snip[a][b] == pic[i+a][j+b])){
							ok = false;
							break;
						}
					}
					if(!ok)
						break;
				}
				if(ok){
					ans.PB(pr(i+1,j+1));
					goto end;
				}
			}
			end:;
			rot();
		}
		if(!ans.empty()){
			sort(BE(ans));
			cout << ans[0].S << " " << ans[0].F << endl;
		}
		else{
			cout << "NA" << endl;
		}
	}
}