#include <bits/stdc++.h>
using namespace std;
const int dx[]={1,0,0,-1,1,-1,-1,1};
const int dy[]={0,1,-1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-8;
#define PB push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(int i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> Pii;
typedef pair<int,vi > P;
typedef long long ll;

int N, M;

void Rotate(int matrix[52][52]){
	int sub[52][52]={{0}};
	rep(i,M){
		rep(j,M){
			sub[j][M-i-1] = matrix[i][j];
		}
	}
	rep(i,M){
		rep(j,M){
			matrix[i][j] = sub[i][j];
		}
	}
	return ;
}

void DEBUG(int matrix[52][52]){
	puts("**********************");
	rep(i,M){
		rep(j,M){
			printf("%3d",matrix[i][j]);
		}
		puts("");
	}
	return ;
}

int main(){
	while(true){
		scanf("%d %d" ,&N ,&M);

		if(N == 0 && M == 0)break;

		int pic[128][128];
		int scene[52][52];

		rep(i,N){
			rep(j,N){
				scanf("%d", &pic[i][j]);
			}
		}

		rep(i,M){
			rep(j,M){
				scanf("%d", &scene[i][j]);
			}
		}
		int ansy = 128;
		int ansx = 128;
		rep(q,4){
			Rotate(scene);
			//DEBUG(scene);
			rep(i,N-M+1){
				rep(j,N-M+1){
					bool flg = true;
					reps(k,i,i+M){
						reps(l,j,j+M){
							if(scene[k-i][l-j] == -1)continue;
							if(pic[k][l] != scene[k-i][l-j]){
								flg = false;
								break;
							}
						}
						if(!flg){
							break;
						}
					}
					if(flg){
						rep(k,M){
							rep(l,M){
								if(scene[k][l] != -1){
									if(ansy*M+ansx > (k+i)*M+l+j){
										ansy = k+i;
										ansx = l+j;
										goto end;
									}
								}
							}
						}
					}
				}
			}
			end:;
		}

		if(ansy < 128){
			printf("%d %d\n",ansx+1, ansy+1);
		}
		else{
			puts("NA");
		}
	}

	return 0;
}