#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
int pic[50][50];
int all[100][100];
int n,m;

void rotate(){
	rep(i,0,m)rep(j,0,i)swap(pic[i][j],pic[j][i]);
	rep(i,0,m)reverse(pic[i],pic[i]+m);
}

int main(){
	bool flag = 0;
	int X,Y,f_x,f_y,first;
	while(cin >> n >> m && n && m){
		X = Y = (1<<21);
		
		rep(i,0,n)rep(j,0,n){
			cin >> all[i][j];
		}
		rep(i,0,m)rep(j,0,m){
			cin >> pic[i][j];
		}
		rep(y,0,n-m+1){
			rep(x,0,n-m+1){
				rep(b,0,4){
					first = flag = true;
					rep(i,0,m)rep(j,0,m){
						//cout << x+j << "," << y+i << endl;
						if(pic[i][j]==-1)continue;
					
						if(pic[i][j]!=all[y+i][x+j]){
							flag = false;
						}else if(first){
							f_y = y+i;
							f_x = x+j;
							first = false;
						}
					}
					if(flag){
						if(f_y < Y){
							Y = f_y;
							X = f_x;
						}else if(f_y == Y){
							if(f_x < X){
								X = f_x;
							}
						}
					}
					rotate();
				}
				
			}
		}
		if( X == (1<<21) )cout << "NA" << endl;
		else cout << X+1 << " " << Y+1 << endl;
	}	
}