#include <iostream>
#include <map>

using namespace std;

int n, m;

void solve()
{
    int grid[n][n];
    int pic[m][m][4]; // 0, 90, 180, 270.

    // Input 窓
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            cin >> grid[i][j];

    // Input 写真
    pair<int, int> top[4]; // (x, y) = (first, second)
    for (int i = 0; i < m; ++i)
        for (int j = 0; j < m; ++j) {
            cin >> pic[i][j][0];
            pic[j][m - i - 1][1] = pic[i][j][0];
            pic[m - i - 1][m - j - 1][2] = pic[i][j][0];
            pic[m - j - 1][i][3] = pic[i][j][0];
        }

    for (int k = 0; k < 4; ++k) {
        bool change = false;
        for (int i = 0; i < m; ++i) {
            if (change)
                break;
            for (int j = 0; j < m; ++j)
                if (pic[i][j][k] != -1) {
                    top[k].first = j;
                    top[k].second = i;
                    change = true;
                    break;
                }
        }
    }

    int ax = n, ay = n;
    bool finish = false;
    for (int i = 0; i + m < n; ++i) {
        for (int j = 0; j + m < n; ++j) {

            for (int k = 0; k < 4; ++k) {
                bool change = true;
                for (int dy = 0; dy < m; ++dy) {
                    if (!change)
                        break;
                    for (int dx = 0; dx < m; ++dx)
                        if (pic[dy][dx][k] != -1 &&
                            grid[i + dy][j + dx] != pic[dy][dx][k]) {
                            change = false;
                            break;
                        }
                }
                if (change) {
                    if ((top[k].second + i < ay) ||
                        (top[k].second + i == ay && top[k].first + j < ax)) {
                        ax = top[k].first + j;
                        ay = top[k].second + i;
                        finish = true;
                    }
                }
            }

            if (finish)
                break;
        }
        if (finish)
            break;
    }

    if (ax != n && ay != n)
        cout << ax + 1 << " " << ay + 1 << endl;
    else
        cout << "NA\n";
}

int main()
{
    while (cin >> n >> m, n || m) {
        solve();
    }

    return 0;
}