#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int n,m;
	
	while(cin >> n >> m){
		if(!(n|m)) break;
		int pic[n][n];
		int pattern[m][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 >> pattern[i][j];
			}
		}

		bool ans[4];
		bool end = true;
		for(int i=0;i<n-m && end;i++){
			for(int j=0;j<n-m && end;j++){
				ans[0] = true;
				ans[1] = true;
				ans[2] = true;
				ans[3] = true;
				for(int p=0;p<m && end;p++){
					for(int q=0;q<m && end;q++){
						if(pattern[p][q] != -1 && pattern[p][q] != pic[i+p][j+q]){
							ans[0] = false;
						}
						if(pattern[p][q] != -1 && pattern[p][q] != pic[(n-1)-j-q][i+p]){
							ans[1] = false;
						}
						if(pattern[p][q] != -1 && pattern[p][q] != pic[(n-1)-i-p][(n-1)-j-q]){
							ans[2] = false;
						}
						if(pattern[p][q] != -1 && pattern[p][q] != pic[j+q][(n-1)-i-p]){
							ans[3] = false;
						}
					}
				}
				if(ans[0] || ans [1] || ans [2] || ans[3]){
					cout << j+1 << " " << i+1 << endl;
					end = false;
				}
			}
		}
		if(end)	cout << "NA" <<endl;
	}
}