#include <iostream>

using namespace std;

void pfunc(int a[51][51], int n, int s, int t)
{
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(a[i][j] != -1){
				cout << (j+t+1) << " " << (i+s+1) << endl;
				return ;
			}
		}
	}
	
	return ;
}

bool check(int pic[101][101], int r[51][51], int m, int s, int t)
{
	for(int i = 0; i < m; i++){
		for(int j = 0; j < m; j++){
			if(r[i][j] == -1){
				continue;
			}
			if(r[i][j] != pic[s+i][t+j]){
				return false;
			}
		}
	}
	
	return true;
}

bool func(int pic[101][101], int r0[51][51], int r90[51][51], int r180[51][51], int r270[51][51], int n, int m)
{
	for(int i = 0, u = n-m-1; i < u; i++){
		for(int j = 0; j < u; j++){
			if(check(pic, r0, m, i, j)){
				pfunc(r0, m, i, j);
				return false;
			} else if(check(pic, r90, m, i, j)){
				pfunc(r90, m, i, j);
				return false;
			} else if(check(pic, r180, m, i, j)){
				pfunc(r180, m, i, j);
				return false;
			} else if(check(pic, r270, m, i, j)){
				pfunc(r270, m, i, j);
				return false;
			}
		}
	}
	
	return true;
}

int main()
{
	int pic[101][101], r0[51][51], r90[51][51], r180[51][51], r270[51][51], n, m;
	
	while(cin>>n>>m && (n+m)){
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> pic[i][j];
			}
		}
		
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				cin >> r0[i][j];
				r270[m-1-j][i] = r180[m-1-i][m-1-j] = r90[j][m-1-i] = r0[i][j];
			}
		}
		
		if(func(pic, r0, r90, r180, r270, n, m)){
			cout << "NA" << endl;
		}
	}
	
	return 0;
}