#include <iostream>
using namespace std;

int field[101][101];
int pattern[50][50];
int next[50][50];

int main() {
    while (true) {
        int n, m;
        cin >> n >> m;
        if ((n | m) == 0) {
            break;
        }
        for (int y = 1; y <= n; y++) {
            for (int x = 1; x <= n; x++) {
                cin >> field[y][x];
            }
        }
        for (int y = 0; y < m; y++) {
            for (int x = 0; x < m; x++) {
                cin >> pattern[y][x];
            }
        }
        pair<int, int> ans = make_pair(n + 1, n + 1);
        for (int i = 0; i < 4; i++) {
            for (int y = 1; y + m - 1 <= n; y++) {
                for (int x = 1; x + m - 1<= n; x++) {
                    pair<int, int> add = make_pair(-1, -1);
                    for (int dy = 0; dy < m; dy++) {
                        for (int dx = 0; dx < m; dx++) {
                            if (add.first == -1 && pattern[dy][dx] >= 0) {
                                add = make_pair(y + dy, x + dx);
                            }
                            if (pattern[dy][dx] >= 0 && pattern[dy][dx] != field[y + dy][x + dx]) {
                                goto endMatch;
                            }
                        }
                    }
                    if ((add.first < ans.first)
                        || (add.first == ans.first && add.second < ans.second)) {
                        ans = add;
                    }
                endMatch:;
                }
            }
            if (i == 3) {
                break;
            }
            for (int y = 0; y < m; y++) {
                for (int x = 0; x < m; x++) {
                    next[y][x] = pattern[m - 1 - x][y];
                }
            }
            for (int y = 0; y < m; y++) {
                for (int x = 0; x < m; x++) {
                    pattern[y][x] = next[y][x];
                }
            }
        }
        if (ans.first > n) {
            cout << "NA" << endl;
        } else {
            cout << ans.second << " " << ans.first << endl;
        }
    }
}