#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

#define MAX_N 100
#define MAX_M 50

int n, m;
int F[MAX_N][MAX_N];
int P[MAX_M][MAX_M];

void rotate90() {
    int buf[m][m];
    for (int i = 0; i < m; i++) 
        for (int j = 0; j < m; j++) 
            buf[i][j] = P[m-j-1][i];
    for (int i = 0; i < m; i++) 
        for (int j = 0; j < m; j++)
            P[i][j] = buf[i][j];
}

pair<int, int> ans;

bool check(int y, int x) {
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < m; j++) {
            if (P[i][j] != -1 && F[y+i][x+j] != P[i][j]) 
                return false;
        }
    }
    //for (int i = 0; i < m; i++) {
    //    for (int j = 0; j < m; j++) 
    //        printf("%3d ", P[i][j]);
    //    printf("\n");
    //}

    return true;
}

void find() {
    for (int i = 0; i < n-m+1; i++) {
        for (int j = 0; j < n-m+1; j++) {
            if (check(i, j)) {
                pair<int, int> t;
                t.first = i+1;
                int k = 0;
                while (P[0][k] == -1) k++;
                t.second = j+k+1;
                ans = min(ans, t);
                return;
            }
        }
    }
}

#define INF (1<<28)

int main() {
    while (cin >> n >> m, n || m) {
        ans.first = ans.second = INF;
        for (int i = 0; i < n; i++) 
            for (int j = 0; j < n; j++) 
                cin >> F[i][j];
        for (int i = 0; i < m; i++) 
            for (int j = 0; j < m; j++) 
                cin >> P[i][j];
        find(); 
        rotate90(); find();
        rotate90(); find();
        rotate90(); find();
        if (ans.first == INF && ans.second == INF) cout << "NA" << endl;
        else cout << ans.second << ' ' << ans.first << endl;
    }
    return 0;
}