#include<iostream>
using namespace std;
int x[110][110];
int p[100][100][4];
int n, m;
int main() {
	while (true) {
		cin >> n >> m;
		if (n == 0 && m == 0) { break; }
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				cin >> x[i][j];
			}
		}
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < m; j++) {
				cin >> p[i][j][0];
			}
		}
		for (int i = 1; i <= 3; i++) {
			for (int j = 0; j < m; j++) {
				for (int k = 0; k < m; k++) {
					p[m - 1 - k][j][i] = p[j][k][i - 1];
				}
			}
		}
		int cnt = 0;
		for (int i = 0; i <= n - m; i++) {
			for (int j = 0; j <= n - m; j++) {
				for (int k = 0; k < 4; k++) {
					bool ok = true;
					for (int l = 0; l < m; l++) {
						for (int o = 0; o < m; o++) {
							if (p[l][o][k] == -1) { continue; }
							if (p[l][o][k] != x[i + l][j + o]) {
								ok = false;
							}
						}
					}
					if (ok == true && cnt == 0) {
						int ok2 = false;
						for (int l = 0; l < m; l++) {
							for (int o = 0; o < m; o++) {
								if (p[l][o][k] >= 0 && ok2 == false) {
									int X = i + l + 1;
									int Y = j + o + 1;
									cout << Y << ' ' << X << endl;
									cnt = 1;
									ok2 = true;
								}
							}
						}
					}
				}
			}
		}
		if (cnt == 0) { cout << "NA" << endl; }
	}
	return 0;
}