#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <sstream>
using namespace std;

int scene[201][201];
int pic[4][51][51];
int n, m;

pair<int,int> getPos(int y, int x, int k) {
    int ry = -1, rx;
    for (int i=0; i<m; ++i) {
        for (int j=0; j<m; ++j) {
            if (0 <= pic[k][i][j]) {
                if (pic[k][i][j] != scene[y+i][x+j]) {
                    return make_pair(-1, -1);
                }
                if (ry == -1) {
                    ry = y+i+1, rx = x+j+1;
                }
            }
        }
    }
    return make_pair(ry, rx);
}

string solve() {
    pair<int,int> ret(101, 101);
    bool ok = false;
    for (int i=0; i+m-1<n; ++i) {
        for (int j=0; j+m-1<n; ++j) {
            for (int k=0; k<4; ++k) {
                pair<int,int> p = getPos(i, j, k);
                if (p.first != -1 && p < ret) {
                    ret = p;
                    ok = true;
                }
            }
        }
    }
    if (ok) {
        stringstream ss;
        ss << ret.second << " " << ret.first;
        return ss.str();
    }
    return "NA";
}

int main() {
    while (cin >> n >> m, n) {
        for (int i=0; i<n; ++i) {
            for (int j=0; j<n; ++j) {
                cin >> scene[i][j];
            }
        }
        for (int i=0; i<m; ++i) {
            for (int j=0; j<m; ++j) {
                cin >> pic[0][i][j];
                pic[1][j][m-1-i] = pic[0][i][j];
                pic[2][m-1-i][m-1-j] = pic[0][i][j];
                pic[3][m-1-j][i] = pic[0][i][j];
            }
        }
        cout << solve() << endl;
    }
    return 0;
}