#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int map[200][200];
int piece[4][100][100];

int main(){
	
	int n, m;
	
	while(true){
		cin >> n >> m;
		if(n == 0 && m == 0){
			break;
		}
		
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				cin >> map[j][i];
			}
		}
		
		for(int i = 0; i < m; i++){
			for(int j = 0; j < m; j++){
				cin >> piece[0][j][i];
			}
		}
		
		for(int loop = 0; loop < 3; loop++){
			for(int i = 0; i < m; i++){
				for(int j = 0; j < m; j++){
					piece[loop + 1][j][i] = piece[loop][m - 1 - i][j];
				}
			}
		}
		
		bool check1, check2;
		
		int ans_x = -1;
		int ans_y = -1;
		int ans_loop = -1;
		
		check1 = false;
		for(int x = 0; x <= n - m; x++){
			for(int y = 0; y <= n - m; y++){
				for(int loop = 0; loop < 4; loop++){
					check2 = false;
					for(int dx = 0; dx < m; dx++){
						for(int dy = 0; dy < m; dy++){
							if(piece[loop][dx][dy] != -1 && map[x + dx][y + dy] != piece[loop][dx][dy]){
								check2 = true;
								break;
							}
						}
						if(check2){
							break;
						}
					}
					if(!check2){
						ans_x = x;
						ans_y = y;
						ans_loop = loop;
						check1 = true;
						break;
					}
				}
				if(check1){
					break;
				}
			}
			if(check1){
				break;
			}
		}
		
		if(ans_x == -1 && ans_y == -1){
			cout << "NA" << endl;
		}else{
			int ans_dx = -1;
			for(int dx = 0; dx < m; dx++){
				if(piece[ans_loop][dx][0] != -1){
					ans_dx = dx;
					break;
				}
			}
			cout << ans_x + ans_dx + 1 << " " << ans_y + 1 << endl;;
		}
		
	}
	
	return 0;
}