#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, m;
	while (scanf("%d %d", &n, &m), n){
		int grid[100][100];
		int pic[4][50][50];
		for (int i = 0; i < n; i++){
			for (int j = 0; j < n; j++){
				scanf("%d", &grid[i][j]);
			}
		}
		for (int i = 0; i < m; i++){
			for (int j = 0; j < m; j++){
				int x;
				scanf("%d", &x);
				pic[0][i][j] = x;
				pic[1][m - j - 1][i] = x;
				pic[2][m - i - 1][m - j - 1] = x;
				pic[3][j][m - i - 1] = x;
			}
		}
		
		pair<int, int> res(114514, 114514);
		
		for (int p = 0; p < 4; p++){
			for (int x = 0; x <= n - m; x++){
				for (int y = 0; y <= n - m; y++){
					bool f = true;
					pair<int, int> t(114514, 114514);
					for (int i = 0; i < m; i++){
						for (int j = 0; j < m; j++){
							if (pic[p][i][j] == -1) continue;
							if (pic[p][i][j] != grid[x + i][y + j]) f = false;
							t = min(t, pair<int, int>(x + i, y + j));
						}
					}
					if (f) res = min(res, t);
				}
			}
		}
		
		if (res == pair<int, int>(114514, 114514)) puts("NA");
		else printf("%d %d\n", ++res.second, ++res.first);
	}
}