#include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;
int main(){
	int n, m;
	while(cin >> n >> m, (n || m)) {
		int x[100][100], y[50][50];
		rep(i,n) {
			rep(j,n) {
				cin >> x[i][j];
			}
		}
		rep(i,m) {
			rep(j,m) {
				cin >> y[i][j];
			}
		}
		int rx = n+1, ry = n+1;
		rep(i,4) {
			int sx = 0, sy = 0;
			rep(j,m) {
				rep(k,m) {	
					if(y[j][k] != -1) {
						sx = k+1, sy = j+1;
						break;
					}					
				}
				if(sx) break;
			}
			bool f = 1;
			rep(j,n-m+1) {
				rep(k,n-m+1) {
					f = 1;
					rep(p,m) {
						rep(q,m) {
							if(y[p][q] != -1 && x[j+p][k+q]!=y[p][q]) {
								f = 0;
								break;
							}
						}
						if(!f) break;
					}
					if(f) {
						sx += k, sy += j;
						break;
					}
				}
				if(f) break;
			}
			if(f && (sy<ry || sy==ry && sx<rx)) {
				rx = sx, ry = sy;
			}
			int n[50][50];
			rep(i,m) {
				rep(j,m) {
					n[i][j] = y[j][m-i-1];
				}
			}
			rep(i,m) {
				rep(j,m) {
					y[i][j] = n[i][j];
				}
			}
		}
		if(rx==n+1&&ry==n+1) cout << "NA" << endl;
		else cout << rx << " " << ry << endl;
	}
}