#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int w[100][100], p[50][50], c[50][50];
int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		rep(i, n)rep(j, n)scanf("%d", &w[i][j]);
		rep(i, m)rep(j, m)scanf("%d", &p[i][j]);
		rep(i, n - m + 1)rep(j, n - m + 1) {
			rep(k, 4) {
				rep(x, m)rep(t, m)c[t][m - x - 1] = p[x][t];
				rep(x, m)rep(t, m)p[x][t] = c[x][t];
				rep(x, m)rep(t, m) {
					if (~p[x][t] && p[x][t] != w[i + x][j + t])goto g;
				}
				rep(x, m)rep(y, m) {
					if (~p[x][y]) {
						printf("%d %d\n", j + y + 1, i + x + 1); goto p;
					}
				}
			g:;
			}
		}
		puts("NA");
	p:;
	}
}