#include <iostream>
#include <cstring>

using namespace std;

const int max_matrix_size = 100;

void p(int a[max_matrix_size][max_matrix_size], int size, int offseti = 0, int offsetj = 0){
	for(int i = 0; i < size; i++){
		for(int j = 0; j < size; j++){
			cout << a[offseti+i][offsetj+j] << ' ';
		}
		cout << endl;
	}
}

// aの[starti][startj]からsize分の正方行列を比較
bool compareMatrix(int a[max_matrix_size][max_matrix_size], int b[max_matrix_size][max_matrix_size], int starti, int startj, int size){
	for(int i = 0; i < size; i++){
		for(int j = 0; j < size; j++){
			if( b[i][j] == -1) continue;
			if(a[starti+i][startj+j] != b[i][j]) return false;
		}
	}
	//p(a, size, starti, startj);
	//p(b, size);

	return true;
}

// 2次元配列を90度回転
void rotateMatrix(int (*a)[max_matrix_size], int size){
	int tmp[max_matrix_size][max_matrix_size];
	for(int i = 0; i < size; i++){
		for(int j = 0; j < size; j++){
			tmp[i][j] = a[j][(size-1)-i];
		}
	}
	memcpy(a, tmp, sizeof(int)*max_matrix_size*max_matrix_size);
}

void printnonnegative(int piece[max_matrix_size][max_matrix_size], int size, int offseti, int offsetj){
	for(int i = 0; i < size; i++){
		for(int j = 0; j < size; j++){
			if(piece[i][j] != -1){
				cout << offsetj+j+1 << ' ' << offseti+i+1 << endl;
				return;
			}
		}
	}
}


void search(int pict[max_matrix_size][max_matrix_size], int pictsize, int piece[max_matrix_size][max_matrix_size], int piecesize ){
	for(int i = 0; i < pictsize - piecesize + 1; i++){
		for(int j = 0; j < pictsize - piecesize + 1; j++){
			//cout << "i = " << i << ", j = " << j << endl;
			for(int k = 0; k < 4; k++){
				//cout << "rotate:" << k*90 << endl;
				if(compareMatrix(pict, piece, i, j, piecesize) == true){
					printnonnegative(piece, piecesize, i, j);
					return;
				}
				rotateMatrix(piece, piecesize);
			}
		}
	}
	cout << "NA" << endl;
}

int main(){
	int picture[max_matrix_size][max_matrix_size];
	int piece[max_matrix_size][max_matrix_size];

	int n, m;
	while(cin >> n >> m){
		if(!n && !m) break;
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> picture[i][j];
			}
		}
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				cin >> piece[i][j];
			}
		}

		search(picture, n, piece, m);
	}

	return 0;
}