#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 = 10000;
		int ans_y = 10000;
		
		check1 = false;
		for(int y = 0; y <= n - m; y++){
			for(int x = 0; x <= n - m; x++){
				for(int loop = 0; loop < 4; loop++){
					check2 = false;
					int first_x = 10000;
					int first_y = 10000;
					for(int dy = 0; dy < m; dy++){
						for(int dx = 0; dx < m; dx++){
							if(piece[loop][dx][dy] != -1){
								if(first_x == 10000){
									first_x = x + dx;
									first_y = y + dy;
								}
								if(map[x + dx][y + dy] != piece[loop][dx][dy]){
									check2 = true;
									break;
								}
							}
						}
						if(check2){
							break;
						}
					}
					if(!check2){
						if(ans_x >= first_x && ans_y >= first_y){
							ans_x = first_x;
							ans_y = first_y;
							check1 = true;
						}
					}
				}
			}
			if(check1){
				break;
			}
		}
		
		if(ans_x == 10000 && ans_y == 10000){
			cout << "NA" << endl;
		}else{
			cout << ans_x + 1 << " " << ans_y + 1 << endl;
		}
		
	}
	
	return 0;
}