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

#define INF 1<<30

vector< vector<int> > rotate(vector< vector<int> > picture) {
    int m = picture.size();
    vector< vector<int> > result(m, vector<int>(m));
    for(int i=0; i<m; i++) for(int j=0; j<m; j++) result[i][j] = picture[j][m-1-i];
    return result;
}

vector<int> check(vector< vector<int> > scene, vector< vector<int> > picture) {
    int n = scene.size();
    int m = picture.size();
    vector<int> result(2, INF);
    bool ok = false;
    for(int r=0; r<4; r++) {
        for(int i=0; i<n-m; i++) for(int j=0; j<n-m; j++) {
            ok = true;
            vector<int> first(2, INF);
            for(int y=0; y<m; y++) for(int x=0; x<m; x++) {
                if(picture[y][x] == -1) continue;
                if(first[0] == INF) {
                    first[0] = i+y+1;
                    first[1] = j+x+1;
                }
                ok &= (scene[i+y][j+x] == picture[y][x]);
            }
            if(ok)
                if((first[0] < result[0]) || (first[0] == result[0] && first[1] < result[1]))
                    result = first;
        }
        picture = rotate(picture);
    }
    return result;
}

int main()
{
    int n, m;
    while(cin>>n>>m, n|m) {
        vector< vector<int> > scene(n, vector<int>(n)), picture(m, vector<int>(m));
        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>>picture[i][j];
        vector<int> ans;
        ans = check(scene, picture);
        if(ans[0] == INF) cout<<"NA"<<endl;
        else cout<<ans[1]<<" "<<ans[0]<<endl;
    }
}