#include<bits/stdc++.h>
using namespace std;
#define rep(i,a) reps(i,0,a)
#define reps(i,a,b) for(int i = (a); i < (b); i++)
typedef vector<int> vi;
inline int get() {int x; cin >> x; return x;}
int field[101][101];
int photo[4][51][51];
int n,m;
bool check(int x, int y, int k) {
	rep(i, m) rep(j, m) {
		if(photo[k][i][j] == -1) continue;
		else if(photo[k][i][j] != field[i+y][j+x]) return false;
	}
	return true;
}
int main() {
	while(cin >> n >> m,n,m){
		rep(i, 101)rep(j,101) field[i][j] = -1;
		rep(i, 51)rep(j,51) field[i][j] = -1;
		rep(i, n)rep(j, n) field[i][j] = get();
		rep(i, m)rep(j, m) photo[0][i][j] = get();
		reps(k, 1, 4)rep(i, m)rep(j, m) {
			int nx = m - i - 1, ny = j;
			photo[k][ny][nx] = photo[k-1][i][j];
		}
		rep(k, 4) rep(i, n - m + 1) rep(j, n - m + 1) {
			if(check(j, i, k)) {
				rep(l,m)rep(o,m) {
					if(photo[k][l][o] != -1) {
						printf("%d %d\n", j + o + 1, i + l + 1);	
						goto end;
					}
				}
			}
		}
		puts("NA");
		end:;
	}
	return 0;
}