#include <stdio.h>

int pat[4][50][50];
int scen[100][100];

void rote(int s, int e, int m)
{
	for (int i = 0; i < m; i++){
		for (int j = 0; j < m; j++){
			pat[e][j][i] = pat[s][i][(m - 1) - j];
		}
	}
}


int main(void)
{
	int n, m;
	int patx, paty;
	bool end;
	
	while (1){
		scanf("%d%d", &n, &m);
		
		if (n == 0 || m == 0){
			break;
		}
		
		for (int y = 0; y < n; y++){
			for (int x = 0; x < n; x++){
				scanf("%d", &scen[x][y]);
			}
		}
		for (int y = 0; y < m; y++){
			for (int x = 0; x < m; x++){
				scanf("%d", &pat[0][x][y]);
			}
		}
		for (int i = 0; i < 3; i++){
			rote(i, i + 1, m);
		}
		
		end = false;
		for (int y = 0; (y + m) < n; y++){
			for (int x = 0; (x + m) < n; x++){
				int dx, dy;
				for (int i = 0; i < 4; i++){
					bool flag;
					flag = true;
					for (dy = 0; dy < m; dy++){
						for (dx = 0; dx < m; dx++){
							if (pat[i][dx][dy] != -1 && scen[x + dx][y + dy] != pat[i][dx][dy]){
								flag = false;
								break;
							}
						}
						if (!flag){
							break;
						}
					}
					if (flag){
						int px, py;
						
						px = py = -1;
						for (dy = 0; dy < m; dy++){
							for (dx = 0; dx < m; dx++){
								if (pat[i][dx][dy] != -1){
									px = dx;
									py = dy;
									break;
								}
							}
							if (px != -1) break;
						}
						end = true;
						printf("%d %d\n", x + px + 1, y + py + 1, i);
						break;
					}
				}
				if (end) break;
			}
			if (end) break;
		}
		
		if (!end){
			printf("NA\n");
		}
	}
	
	return (0);
}