#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-10;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
#define repD(i, n) for(int i = n; i >= 0; i--)

int n, m;
int scene[100][100];
int pic[4][50][50];
P res[4];

P check(int v){
	rep(i, n - m + 1)rep(j, n - m + 1){
		bool ok = true;
		P p = P(INF, INF);
		rep(k, m)rep(l, m){
			if(pic[v][k][l] >= 0 && scene[i+k][j+l] != pic[v][k][l]) ok = false; 
			else if(pic[v][k][l] >= 0 && p.first == INF) p = P(i+k+1, j+l+1);
		}
		if(ok) return p;
	}
	return P(INF, INF);
}

int main(){
	while(cin >> n >> m && (n || m)){
		rep(i, n) rep(j, n) cin >> scene[i][j];
		rep(i, m) rep(j, m){
			cin >> pic[0][i][j];
			pic[1][j][m-i-1] = pic[0][i][j];
			pic[2][m-i-1][m-j-1] = pic[0][i][j];
			pic[3][m-j-1][i] = pic[0][i][j];

		}
		fill(res, res + 4, P(INF, INF));

		rep(i,4){
			res[i] = check(i);
		}

		sort(res, res + 4);
		if(res[0].first == INF) cout << "NA" << endl;
		else cout << res[0].second << " " << res[0].first << endl;
	}
	return 0;
}